File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
packages/dev-middleware/src/inspector-proxy Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -94,13 +94,21 @@ export default class InspectorProxy implements InspectorProxyQueries {
9494 response : ServerResponse ,
9595 next : ( ?Error ) = > mixed ,
9696 ) {
97- const path = url . parse ( request . url ) . pathname ;
97+ // When request.url is a relative path, the WHATWG URL constructor will require
98+ // the second "base" param otherwise an exception will be thrown.
99+ // We could use `http://${request.headers.host}` here instead however:
100+ // - We are forced to make an assumption about the scheme so if someone is running
101+ // Metro over https it could cause confusion.
102+ //
103+ // - We are only extracting pathname from the parsed URL so the host portion is
104+ // irrelevant.
105+ const pathname = new URL ( request . url , 'http://example' ) . pathname ;
98106 if (
99- path === PAGES_LIST_JSON_URL ||
100- path === PAGES_LIST_JSON_URL_2
107+ pathname === PAGES_LIST_JSON_URL ||
108+ pathname === PAGES_LIST_JSON_URL_2
101109 ) {
102110 this . _sendJsonResponse ( response , this . getPageDescriptions ( ) ) ;
103- } else if ( path === PAGES_LIST_JSON_VERSION_URL ) {
111+ } else if ( pathname === PAGES_LIST_JSON_VERSION_URL ) {
104112 this . _sendJsonResponse ( response , {
105113 Browser : 'Mobile JavaScript' ,
106114 'Protocol-Version' : '1.1' ,
You can’t perform that action at this time.
0 commit comments