Skip to content

Commit

Permalink
Using built-in url parsing library (#325)
Browse files Browse the repository at this point in the history
* Using built-in url parsing library

* Fix deprecated url.parse and linting problems

* Remove un-needed const line

Co-authored-by: Alexander J. Lallier <alexanderlallier@gmail.com>
  • Loading branch information
amygrinn and alallier authored Jan 2, 2023
1 parent 6e520df commit e186876
Show file tree
Hide file tree
Showing 3 changed files with 3,355 additions and 3,365 deletions.
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

0 comments on commit e186876

Please sign in to comment.