mirror of
https://github.com/facebook/react-native.git
synced 2024-11-21 12:39:27 +00:00
Remove URL.canParse, fix older Node compatibility
Summary:
`URL.canParse` was added to Node.js [in v18.17.0](9586cd0cfd
).
Internally, we have call sites using earlier versions of Node.js.
Changelog:
[General][Fixed]: dev-middleware: Remove URL.canParse, restore compat with Node < 18.17
Reviewed By: rshest
Differential Revision: D66158204
fbshipit-source-id: e7a846b536e76672cea9afd5bdc5041d50a8b587
This commit is contained in:
parent
29a0d7c3b2
commit
99767d43b0
@ -24,5 +24,9 @@ export default function getBaseUrlFromRequest(
|
||||
// https://github.com/nodejs/node/issues/41863#issuecomment-1030709186
|
||||
const scheme = req.socket.encrypted === true ? 'https' : 'http';
|
||||
const url = `${scheme}://${req.headers.host}`;
|
||||
return URL.canParse(url) ? new URL(url) : null;
|
||||
try {
|
||||
return new URL(url);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user