Skip to content

Commit e186876

Browse files
amygrinnalallier
andauthored
Using built-in url parsing library (#325)
* Using built-in url parsing library * Fix deprecated url.parse and linting problems * Remove un-needed const line Co-authored-by: Alexander J. Lallier <[email protected]>
1 parent 6e520df commit e186876

File tree

3 files changed

+3355
-3365
lines changed

3 files changed

+3355
-3365
lines changed

lib/reload-server.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const argv = require('minimist')(process.argv.slice(2))
77

88
const serveStatic = require('serve-static')
99
const finalhandler = require('finalhandler')
10-
const URL = require('url-parse')
1110

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

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

3533
const fileEnding = pathname.split('.')[1]
3634
const noFileEnding = fileEnding === undefined

0 commit comments

Comments
 (0)