-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace node:url with native url? #2291
Comments
Yeah, don't see a reason why not. |
I was triaging this issue a bit and came into conclusion that replacing the
// WHATWG URL API replacement for url.resolve function
export function urlResolve(from, to) {
const resolvedUrl = new URL(to, new URL(from, 'resolve://'));
if (resolvedUrl.protocol === 'resolve:') {
// `from` is a relative URL.
const { pathname, search, hash } = resolvedUrl;
return pathname + search + hash;
}
return resolvedUrl.toString();
} But |
Found an inconsistency in WHATWG URL parsing. Before this inconsistency is addressed, let's put this issue on hold. Inconsistency described here: whatwg/url#677 |
url package have been removed in #3137 Codebase now contains helper function for parsing URI References that looks like this: /**
* `parseURIReference` function simulates the behavior of `node:url` parse function.
* New WHATWG URL API is not capable of parsing relative references natively,
* but can be adapter by utilizing the `base` parameter.
*/
const parseURIReference = (uriReference) => {
try {
return new URL(uriReference);
} catch {
const parsedURL = new URL(uriReference, 'https://swagger.io');
const pathname = String(uriReference).startsWith('/')
? parsedURL.pathname
: parsedURL.pathname.substring(1);
return {
hash: parsedURL.hash,
host: '',
hostname: '',
href: '',
origin: '',
password: '',
pathname,
port: '',
protocol: '',
search: parsedURL.search,
searchParams: parsedURL.searchParams,
};
}
}; |
🎉 This issue has been resolved in version 3.21.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
swagger-js/src/index.js
Lines 86 to 102 in ba0db61
The text was updated successfully, but these errors were encountered: