Skip to content

Local server: split apart the constructor#17

Open
sdemjanenko wants to merge 1 commit intomasterfrom
local_server_constructor
Open

Local server: split apart the constructor#17
sdemjanenko wants to merge 1 commit intomasterfrom
local_server_constructor

Conversation

@sdemjanenko
Copy link
Copy Markdown
Collaborator

This method was getting pretty hard to follow.

This method was getting pretty hard to follow.
Comment on lines +41 to +58
// host worker and head
app.use(async (req, resp, next) => {
let pageType
if (req.url.match(/^\/worker/)) {
pageType = 'worker'
} else {
const pathname = req._parsedUrl.pathname
if (pathname.match(/^\/(index(\.htm(l)?)?)?$/)) {
pageType = 'head'
}
}

if (pageType) {
resp.end(Zen.indexHtml(pageType))
} else {
next()
}
})
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems much bigger than the 1 line it was previously.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell the previous 1 line was sending head.js to any request that failed to match a route. This new code should send a 404 if an unknown asset is requested.

@rogueg rogueg self-requested a review March 31, 2020 23:19
@rogueg rogueg removed their request for review August 24, 2020 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants