Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using built-in url parsing library #325

Merged
merged 4 commits into from
Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/reload-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const argv = require('minimist')(process.argv.slice(2))

const serveStatic = require('serve-static')
const finalhandler = require('finalhandler')
const URL = require('url-parse')

const port = argv._[0]
const dir = argv._[1]
Expand All @@ -29,8 +28,7 @@ let reloadReturned
const serve = serveStatic(dir, { index: ['index.html', 'index.htm'] })

const server = http.createServer(function (req, res) {
const url = new URL(req.url)
let pathname = url.pathname.replace(/(\/)(.*)/, '$2') // Strip leading `/` so we can find files on file system
let pathname = new URL(req.url, `http://${hostname}`).pathname.slice(1)

const fileEnding = pathname.split('.')[1]
const noFileEnding = fileEnding === undefined
Expand Down
Loading