Skip to content
Closed
Changes from 1 commit
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
7 changes: 4 additions & 3 deletions packages/dev-middleware/src/inspector-proxy/InspectorProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ export default class InspectorProxy implements InspectorProxyQueries {
response: ServerResponse,
next: (?Error) => mixed,
) {
const path = url.parse(request.url).pathname;
Copy link
Member

Choose a reason for hiding this comment

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

From CI, I think there's a formatting fix to apply in this file. Please run yarn format from the repo root.

nit: While we're here, we can modernise this call to use the WHATWG URL API.

Suggested change
const path = url.parse(request.url).pathname;
const path = new URL(request.url).pathname;

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use pathname as well for clarity.

Copy link
Author

Choose a reason for hiding this comment

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

I have made these changes in the latest commit - please see comment above usage of the WHATWG constructor and confirm that the change is appropriate.

Copy link
Contributor

@robhogan robhogan Oct 16, 2023

Choose a reason for hiding this comment

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

I might change this back before merging tbh - your comment raises good points (url is in many ways a more ergonomic API than URL), but you can leave this with us. Thanks again for fixing this issue.

if (
request.url === PAGES_LIST_JSON_URL ||
request.url === PAGES_LIST_JSON_URL_2
path === PAGES_LIST_JSON_URL ||
path === PAGES_LIST_JSON_URL_2
) {
this._sendJsonResponse(response, this.getPageDescriptions());
} else if (request.url === PAGES_LIST_JSON_VERSION_URL) {
} else if (path === PAGES_LIST_JSON_VERSION_URL) {
this._sendJsonResponse(response, {
Browser: 'Mobile JavaScript',
'Protocol-Version': '1.1',
Expand Down