Replace parseurl with WHATWG URL API#315
Conversation
More information here: e18e/ecosystem-issues#160
|
Stale pull request message |
There was a problem hiding this comment.
Pull Request Overview
This PR replaces the use of the deprecated parseurl package with the WHATWG URL API to obtain the pathname from the request object.
- Removed dependency on parseurl
- Updated logic for retrieving the request pathname using the WHATWG URL API
Files not reviewed (1)
- package.json: Language not supported
|
|
||
| defineGetter(req, 'path', function path() { | ||
| return parse(this).pathname; | ||
| return new URL(this).pathname; |
There was a problem hiding this comment.
Using 'new URL(this)' may throw an error if 'this' does not contain an absolute URL. Consider providing a valid absolute URL string or a base URL as the second parameter to ensure proper parsing.
| return new URL(this).pathname; | |
| const baseUrl = `${this.protocol || 'http'}://${this.host || 'localhost'}`; | |
| return new URL(this.url, baseUrl).pathname; |
|
Stale pull request message |
Hmm, ok? :) |
|
Stale pull request message |
|
Do you need something from me to make this PR easier to close? |
|
Hi @Saturate Copilot actually caught a real issue here.
Example: |
|
Stale pull request message |
|
Stale pull request message |
The URL constructor requires an absolute URL string, not a request object. Use this.url with a constructed base URL to handle relative paths like '/some/path?name=foo' that parseurl previously handled. Also fix pre-existing eslint no-extraneous-dependencies error in type declaration tests.
More information here:
e18e/ecosystem-issues#160