Initial commit
This commit is contained in:
commit
78f8d225ee
21173 changed files with 2907774 additions and 0 deletions
34
node_modules/next/dist/shared/lib/router/utils/parse-relative-url.js
generated
vendored
Normal file
34
node_modules/next/dist/shared/lib/router/utils/parse-relative-url.js
generated
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "parseRelativeUrl", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return parseRelativeUrl;
|
||||
}
|
||||
});
|
||||
const _utils = require("../../utils");
|
||||
const _querystring = require("./querystring");
|
||||
function parseRelativeUrl(url, base, parseQuery) {
|
||||
if (parseQuery === void 0) parseQuery = true;
|
||||
const globalBase = new URL(typeof window === 'undefined' ? 'http://n' : (0, _utils.getLocationOrigin)());
|
||||
const resolvedBase = base ? new URL(base, globalBase) : url.startsWith('.') ? new URL(typeof window === 'undefined' ? 'http://n' : window.location.href) : globalBase;
|
||||
const { pathname, searchParams, search, hash, href, origin } = new URL(url, resolvedBase);
|
||||
if (origin !== globalBase.origin) {
|
||||
throw Object.defineProperty(new Error("invariant: invalid relative URL, router received " + url), "__NEXT_ERROR_CODE", {
|
||||
value: "E159",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
return {
|
||||
pathname,
|
||||
query: parseQuery ? (0, _querystring.searchParamsToUrlQuery)(searchParams) : undefined,
|
||||
search,
|
||||
hash,
|
||||
href: href.slice(origin.length)
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parse-relative-url.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue