@prismicio/next 2.3.4-pr.175.5f9614e → 2.3.4-pr.175.88bf097
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PrismicPreview.cjs +22 -6
- package/dist/PrismicPreview.cjs.map +1 -1
- package/dist/PrismicPreview.d.cts.map +1 -1
- package/dist/PrismicPreview.d.ts.map +1 -1
- package/dist/PrismicPreview.js +20 -6
- package/dist/PrismicPreview.js.map +1 -1
- package/dist/PrismicPreviewClient.cjs +1 -11
- package/dist/PrismicPreviewClient.cjs.map +1 -1
- package/dist/PrismicPreviewClient.js +1 -9
- package/dist/PrismicPreviewClient.js.map +1 -1
- package/dist/exitPreview.cjs +1 -2
- package/dist/exitPreview.cjs.map +1 -1
- package/dist/exitPreview.d.cts.map +1 -1
- package/dist/exitPreview.d.ts.map +1 -1
- package/dist/exitPreview.js +1 -2
- package/dist/exitPreview.js.map +1 -1
- package/dist/lib/getSafePath.cjs +21 -0
- package/dist/lib/getSafePath.cjs.map +1 -0
- package/dist/lib/getSafePath.js +21 -0
- package/dist/lib/getSafePath.js.map +1 -0
- package/dist/package.cjs +1 -1
- package/dist/package.js +1 -1
- package/dist/pages/PrismicPreview.cjs +4 -3
- package/dist/pages/PrismicPreview.cjs.map +1 -1
- package/dist/pages/PrismicPreview.d.cts.map +1 -1
- package/dist/pages/PrismicPreview.d.ts.map +1 -1
- package/dist/pages/PrismicPreview.js +5 -4
- package/dist/pages/PrismicPreview.js.map +1 -1
- package/dist/pages/appendCookie.cjs +2 -4
- package/dist/pages/appendCookie.cjs.map +1 -1
- package/dist/pages/appendCookie.js +2 -4
- package/dist/pages/appendCookie.js.map +1 -1
- package/dist/pages/exitPreview.cjs +2 -2
- package/dist/pages/exitPreview.cjs.map +1 -1
- package/dist/pages/exitPreview.d.cts.map +1 -1
- package/dist/pages/exitPreview.d.ts.map +1 -1
- package/dist/pages/exitPreview.js +2 -2
- package/dist/pages/exitPreview.js.map +1 -1
- package/dist/pages/redirectToPreviewURL.cjs +9 -13
- package/dist/pages/redirectToPreviewURL.cjs.map +1 -1
- package/dist/pages/redirectToPreviewURL.d.cts +1 -1
- package/dist/pages/redirectToPreviewURL.d.ts +1 -1
- package/dist/pages/redirectToPreviewURL.js +9 -13
- package/dist/pages/redirectToPreviewURL.js.map +1 -1
- package/dist/redirectToPreviewURL.cjs +9 -13
- package/dist/redirectToPreviewURL.cjs.map +1 -1
- package/dist/redirectToPreviewURL.d.cts +1 -1
- package/dist/redirectToPreviewURL.d.ts +1 -1
- package/dist/redirectToPreviewURL.js +9 -13
- package/dist/redirectToPreviewURL.js.map +1 -1
- package/package.json +5 -2
- package/src/PrismicPreview.tsx +10 -1
- package/src/PrismicPreviewClient.tsx +1 -12
- package/src/exitPreview.ts +1 -3
- package/src/lib/getSafePath.ts +22 -0
- package/src/pages/PrismicPreview.tsx +5 -4
- package/src/pages/appendCookie.ts +5 -11
- package/src/pages/exitPreview.ts +5 -2
- package/src/pages/redirectToPreviewURL.ts +14 -15
- package/src/redirectToPreviewURL.ts +19 -15
- package/dist/lib/toolbarV5.cjs +0 -37
- package/dist/lib/toolbarV5.cjs.map +0 -1
- package/dist/lib/toolbarV5.js +0 -34
- package/dist/lib/toolbarV5.js.map +0 -1
- package/src/lib/toolbarV5.ts +0 -54
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cookie as prismicCookie, type Client, type LinkResolverFunction } from "@prismicio/client"
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { getSafePath } from "./lib/getSafePath"
|
|
4
4
|
import type { NextRequestLike } from "./types"
|
|
5
5
|
|
|
6
6
|
export type RedirectToPreviewURLConfig = {
|
|
@@ -8,7 +8,7 @@ export type RedirectToPreviewURLConfig = {
|
|
|
8
8
|
// `Pick` is used to use the smallest possible subset of
|
|
9
9
|
// `prismic.Client`. Doing this reduces the surface area for breaking
|
|
10
10
|
// type changes.
|
|
11
|
-
client: Pick<Client, "resolvePreviewURL"
|
|
11
|
+
client: Pick<Client, "resolvePreviewURL">
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* The `request` object from a Next.js Route Handler.
|
|
@@ -45,29 +45,33 @@ export async function redirectToPreviewURL(config: RedirectToPreviewURLConfig):
|
|
|
45
45
|
// tsdown.config.ts for Next.js's server alias) is not resolvable by Node.js.
|
|
46
46
|
const { redirect } = await import("next/navigation")
|
|
47
47
|
|
|
48
|
-
const
|
|
49
|
-
const documentID = searchParams.get("documentId") ?? undefined
|
|
50
|
-
let previewToken = searchParams.get("token") ?? undefined
|
|
51
|
-
const cookieJar = await cookies()
|
|
52
|
-
|
|
53
|
-
// The toolbar's v5 flow follows the session. Share links only carry the session.
|
|
54
|
-
const session = searchParams.get("session")
|
|
55
|
-
if (session) {
|
|
56
|
-
previewToken ??= await getPreviewSessionRef(client, session)
|
|
57
|
-
cookieJar.set(previewSessionCookie, session, { sameSite: "none", secure: true })
|
|
58
|
-
}
|
|
48
|
+
const documentID = request.nextUrl.searchParams.get("documentId") ?? undefined
|
|
59
49
|
|
|
60
50
|
// Set the initial preview cookie. Setting the cookie here is necessary
|
|
61
51
|
// to support unpublished previews. Without setting it here, the page
|
|
62
52
|
// will try to render without the preview cookie, leading to a
|
|
63
53
|
// PrismicNotFound error.
|
|
54
|
+
const cookieJar = await cookies()
|
|
55
|
+
const previewToken = request.nextUrl.searchParams.get("token") ?? undefined
|
|
64
56
|
if (previewToken) {
|
|
65
57
|
cookieJar.set(prismicCookie.preview, previewToken, { sameSite: "none", secure: true })
|
|
66
58
|
}
|
|
67
59
|
|
|
60
|
+
// The toolbar's v5 flow follows this session.
|
|
61
|
+
const session = request.nextUrl.searchParams.get("session")
|
|
62
|
+
if (session) {
|
|
63
|
+
cookieJar.set(prismicCookie.previewSession, session, { sameSite: "none", secure: true })
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Share links return to the page they were opened from.
|
|
68
67
|
const previewURL =
|
|
69
|
-
|
|
70
|
-
(await client.resolvePreviewURL({
|
|
68
|
+
getSafePath(request.nextUrl.searchParams.get("path")) ??
|
|
69
|
+
(await client.resolvePreviewURL({
|
|
70
|
+
documentID,
|
|
71
|
+
previewToken,
|
|
72
|
+
defaultURL,
|
|
73
|
+
linkResolver,
|
|
74
|
+
}))
|
|
71
75
|
|
|
72
76
|
;(await draftMode()).enable()
|
|
73
77
|
|
package/dist/lib/toolbarV5.cjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
let _prismicio_client = require("@prismicio/client");
|
|
2
|
-
//#region src/lib/toolbarV5.ts
|
|
3
|
-
/** The cookie storing the preview session ID. The toolbar's v5 flow follows this session. */
|
|
4
|
-
const previewSessionCookie = "io.prismic.previewSession";
|
|
5
|
-
/**
|
|
6
|
-
* Props for the toolbar's `<script>`, opting into its v5 flow.
|
|
7
|
-
*
|
|
8
|
-
* @param previewURL - The app's preview route, as passed to `fetch()`.
|
|
9
|
-
*/
|
|
10
|
-
function getToolbarScriptProps(repositoryName, previewURL) {
|
|
11
|
-
return {
|
|
12
|
-
src: `${(0, _prismicio_client.getToolbarSrc)(repositoryName)}&v=5`,
|
|
13
|
-
"data-preview-url": typeof window === "undefined" ? void 0 : new URL(previewURL, document.baseURI).href
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
/** Fetches the current ref of a preview session, for share links that only carry the session. */
|
|
17
|
-
async function getPreviewSessionRef(client, session) {
|
|
18
|
-
const url = new URL(`/previews/token/${encodeURIComponent(session)}`, client.documentAPIEndpoint);
|
|
19
|
-
url.hostname = url.hostname.replace(".cdn.", ".");
|
|
20
|
-
const json = await (await fetch(url, { cache: "no-store" })).json();
|
|
21
|
-
if (!json.ref) throw new _prismicio_client.PreviewTokenExpiredError("This preview session has expired", url.href, json);
|
|
22
|
-
return json.ref;
|
|
23
|
-
}
|
|
24
|
-
/** Returns `path` if it is a path on the same origin, like `/blog?page=2`. */
|
|
25
|
-
function getSafePath(path) {
|
|
26
|
-
if (!path?.startsWith("/") || path.startsWith("//") || path.startsWith("/\\")) return;
|
|
27
|
-
const origin = "https://placeholder.invalid";
|
|
28
|
-
const url = new URL(path, origin);
|
|
29
|
-
if (url.origin === origin) return url.href.slice(27);
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
exports.getPreviewSessionRef = getPreviewSessionRef;
|
|
33
|
-
exports.getSafePath = getSafePath;
|
|
34
|
-
exports.getToolbarScriptProps = getToolbarScriptProps;
|
|
35
|
-
exports.previewSessionCookie = previewSessionCookie;
|
|
36
|
-
|
|
37
|
-
//# sourceMappingURL=toolbarV5.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toolbarV5.cjs","names":["getToolbarSrc","PreviewTokenExpiredError"],"sources":["../../src/lib/toolbarV5.ts"],"sourcesContent":["import { getToolbarSrc, PreviewTokenExpiredError, type Client } from \"@prismicio/client\"\n\n/** The cookie storing the preview session ID. The toolbar's v5 flow follows this session. */\nexport const previewSessionCookie = \"io.prismic.previewSession\"\n\n/**\n * Props for the toolbar's `<script>`, opting into its v5 flow.\n *\n * @param previewURL - The app's preview route, as passed to `fetch()`.\n */\nexport function getToolbarScriptProps(\n\trepositoryName: string,\n\tpreviewURL: string,\n): { src: string; \"data-preview-url\"?: string } {\n\treturn {\n\t\t// TODO: Use `getToolbarSrc()` once `@prismicio/client` adds `v=5`.\n\t\tsrc: `${getToolbarSrc(repositoryName)}&v=5`,\n\t\t// The toolbar builds share links with this URL. `next/script` adds `lazyOnload` scripts in\n\t\t// the browser, where the URL is known.\n\t\t\"data-preview-url\":\n\t\t\ttypeof window === \"undefined\" ? undefined : new URL(previewURL, document.baseURI).href,\n\t}\n}\n\n/** Fetches the current ref of a preview session, for share links that only carry the session. */\nexport async function getPreviewSessionRef(\n\tclient: Pick<Client, \"documentAPIEndpoint\">,\n\tsession: string,\n): Promise<string> {\n\tconst url = new URL(`/previews/token/${encodeURIComponent(session)}`, client.documentAPIEndpoint)\n\t// The endpoint is on the repository host, not on its CDN.\n\turl.hostname = url.hostname.replace(\".cdn.\", \".\")\n\tconst res = await fetch(url, { cache: \"no-store\" })\n\tconst json = await res.json()\n\tif (!json.ref) {\n\t\t// Like the Content API's response to an expired preview token.\n\t\tthrow new PreviewTokenExpiredError(\"This preview session has expired\", url.href, json)\n\t}\n\n\treturn json.ref\n}\n\n/** Returns `path` if it is a path on the same origin, like `/blog?page=2`. */\nexport function getSafePath(path: string | undefined | null): string | undefined {\n\tif (!path?.startsWith(\"/\") || path.startsWith(\"//\") || path.startsWith(\"/\\\\\")) {\n\t\treturn\n\t}\n\n\tconst origin = \"https://placeholder.invalid\"\n\tconst url = new URL(path, origin)\n\tif (url.origin === origin) {\n\t\treturn url.href.slice(origin.length)\n\t}\n}\n"],"mappings":";;;AAGA,MAAa,uBAAuB;;;;;;AAOpC,SAAgB,sBACf,gBACA,YAC+C;CAC/C,OAAO;EAEN,KAAK,IAAA,GAAGA,kBAAAA,cAAAA,CAAc,cAAc,EAAE;EAGtC,oBACC,OAAO,WAAW,cAAc,KAAA,IAAY,IAAI,IAAI,YAAY,SAAS,OAAO,CAAC,CAAC;CACpF;AACD;;AAGA,eAAsB,qBACrB,QACA,SACkB;CAClB,MAAM,MAAM,IAAI,IAAI,mBAAmB,mBAAmB,OAAO,KAAK,OAAO,mBAAmB;CAEhG,IAAI,WAAW,IAAI,SAAS,QAAQ,SAAS,GAAG;CAEhD,MAAM,OAAO,OAAM,MADD,MAAM,KAAK,EAAE,OAAO,WAAW,CAAC,EAAA,CAC3B,KAAK;CAC5B,IAAI,CAAC,KAAK,KAET,MAAM,IAAIC,kBAAAA,yBAAyB,oCAAoC,IAAI,MAAM,IAAI;CAGtF,OAAO,KAAK;AACb;;AAGA,SAAgB,YAAY,MAAqD;CAChF,IAAI,CAAC,MAAM,WAAW,GAAG,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,WAAW,KAAK,GAC3E;CAGD,MAAM,SAAS;CACf,MAAM,MAAM,IAAI,IAAI,MAAM,MAAM;CAChC,IAAI,IAAI,WAAW,QAClB,OAAO,IAAI,KAAK,MAAM,EAAa;AAErC"}
|
package/dist/lib/toolbarV5.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { PreviewTokenExpiredError, getToolbarSrc } from "@prismicio/client";
|
|
2
|
-
//#region src/lib/toolbarV5.ts
|
|
3
|
-
/** The cookie storing the preview session ID. The toolbar's v5 flow follows this session. */
|
|
4
|
-
const previewSessionCookie = "io.prismic.previewSession";
|
|
5
|
-
/**
|
|
6
|
-
* Props for the toolbar's `<script>`, opting into its v5 flow.
|
|
7
|
-
*
|
|
8
|
-
* @param previewURL - The app's preview route, as passed to `fetch()`.
|
|
9
|
-
*/
|
|
10
|
-
function getToolbarScriptProps(repositoryName, previewURL) {
|
|
11
|
-
return {
|
|
12
|
-
src: `${getToolbarSrc(repositoryName)}&v=5`,
|
|
13
|
-
"data-preview-url": typeof window === "undefined" ? void 0 : new URL(previewURL, document.baseURI).href
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
/** Fetches the current ref of a preview session, for share links that only carry the session. */
|
|
17
|
-
async function getPreviewSessionRef(client, session) {
|
|
18
|
-
const url = new URL(`/previews/token/${encodeURIComponent(session)}`, client.documentAPIEndpoint);
|
|
19
|
-
url.hostname = url.hostname.replace(".cdn.", ".");
|
|
20
|
-
const json = await (await fetch(url, { cache: "no-store" })).json();
|
|
21
|
-
if (!json.ref) throw new PreviewTokenExpiredError("This preview session has expired", url.href, json);
|
|
22
|
-
return json.ref;
|
|
23
|
-
}
|
|
24
|
-
/** Returns `path` if it is a path on the same origin, like `/blog?page=2`. */
|
|
25
|
-
function getSafePath(path) {
|
|
26
|
-
if (!path?.startsWith("/") || path.startsWith("//") || path.startsWith("/\\")) return;
|
|
27
|
-
const origin = "https://placeholder.invalid";
|
|
28
|
-
const url = new URL(path, origin);
|
|
29
|
-
if (url.origin === origin) return url.href.slice(27);
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
export { getPreviewSessionRef, getSafePath, getToolbarScriptProps, previewSessionCookie };
|
|
33
|
-
|
|
34
|
-
//# sourceMappingURL=toolbarV5.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toolbarV5.js","names":[],"sources":["../../src/lib/toolbarV5.ts"],"sourcesContent":["import { getToolbarSrc, PreviewTokenExpiredError, type Client } from \"@prismicio/client\"\n\n/** The cookie storing the preview session ID. The toolbar's v5 flow follows this session. */\nexport const previewSessionCookie = \"io.prismic.previewSession\"\n\n/**\n * Props for the toolbar's `<script>`, opting into its v5 flow.\n *\n * @param previewURL - The app's preview route, as passed to `fetch()`.\n */\nexport function getToolbarScriptProps(\n\trepositoryName: string,\n\tpreviewURL: string,\n): { src: string; \"data-preview-url\"?: string } {\n\treturn {\n\t\t// TODO: Use `getToolbarSrc()` once `@prismicio/client` adds `v=5`.\n\t\tsrc: `${getToolbarSrc(repositoryName)}&v=5`,\n\t\t// The toolbar builds share links with this URL. `next/script` adds `lazyOnload` scripts in\n\t\t// the browser, where the URL is known.\n\t\t\"data-preview-url\":\n\t\t\ttypeof window === \"undefined\" ? undefined : new URL(previewURL, document.baseURI).href,\n\t}\n}\n\n/** Fetches the current ref of a preview session, for share links that only carry the session. */\nexport async function getPreviewSessionRef(\n\tclient: Pick<Client, \"documentAPIEndpoint\">,\n\tsession: string,\n): Promise<string> {\n\tconst url = new URL(`/previews/token/${encodeURIComponent(session)}`, client.documentAPIEndpoint)\n\t// The endpoint is on the repository host, not on its CDN.\n\turl.hostname = url.hostname.replace(\".cdn.\", \".\")\n\tconst res = await fetch(url, { cache: \"no-store\" })\n\tconst json = await res.json()\n\tif (!json.ref) {\n\t\t// Like the Content API's response to an expired preview token.\n\t\tthrow new PreviewTokenExpiredError(\"This preview session has expired\", url.href, json)\n\t}\n\n\treturn json.ref\n}\n\n/** Returns `path` if it is a path on the same origin, like `/blog?page=2`. */\nexport function getSafePath(path: string | undefined | null): string | undefined {\n\tif (!path?.startsWith(\"/\") || path.startsWith(\"//\") || path.startsWith(\"/\\\\\")) {\n\t\treturn\n\t}\n\n\tconst origin = \"https://placeholder.invalid\"\n\tconst url = new URL(path, origin)\n\tif (url.origin === origin) {\n\t\treturn url.href.slice(origin.length)\n\t}\n}\n"],"mappings":";;;AAGA,MAAa,uBAAuB;;;;;;AAOpC,SAAgB,sBACf,gBACA,YAC+C;CAC/C,OAAO;EAEN,KAAK,GAAG,cAAc,cAAc,EAAE;EAGtC,oBACC,OAAO,WAAW,cAAc,KAAA,IAAY,IAAI,IAAI,YAAY,SAAS,OAAO,CAAC,CAAC;CACpF;AACD;;AAGA,eAAsB,qBACrB,QACA,SACkB;CAClB,MAAM,MAAM,IAAI,IAAI,mBAAmB,mBAAmB,OAAO,KAAK,OAAO,mBAAmB;CAEhG,IAAI,WAAW,IAAI,SAAS,QAAQ,SAAS,GAAG;CAEhD,MAAM,OAAO,OAAM,MADD,MAAM,KAAK,EAAE,OAAO,WAAW,CAAC,EAAA,CAC3B,KAAK;CAC5B,IAAI,CAAC,KAAK,KAET,MAAM,IAAI,yBAAyB,oCAAoC,IAAI,MAAM,IAAI;CAGtF,OAAO,KAAK;AACb;;AAGA,SAAgB,YAAY,MAAqD;CAChF,IAAI,CAAC,MAAM,WAAW,GAAG,KAAK,KAAK,WAAW,IAAI,KAAK,KAAK,WAAW,KAAK,GAC3E;CAGD,MAAM,SAAS;CACf,MAAM,MAAM,IAAI,IAAI,MAAM,MAAM;CAChC,IAAI,IAAI,WAAW,QAClB,OAAO,IAAI,KAAK,MAAM,EAAa;AAErC"}
|
package/src/lib/toolbarV5.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { getToolbarSrc, PreviewTokenExpiredError, type Client } from "@prismicio/client"
|
|
2
|
-
|
|
3
|
-
/** The cookie storing the preview session ID. The toolbar's v5 flow follows this session. */
|
|
4
|
-
export const previewSessionCookie = "io.prismic.previewSession"
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Props for the toolbar's `<script>`, opting into its v5 flow.
|
|
8
|
-
*
|
|
9
|
-
* @param previewURL - The app's preview route, as passed to `fetch()`.
|
|
10
|
-
*/
|
|
11
|
-
export function getToolbarScriptProps(
|
|
12
|
-
repositoryName: string,
|
|
13
|
-
previewURL: string,
|
|
14
|
-
): { src: string; "data-preview-url"?: string } {
|
|
15
|
-
return {
|
|
16
|
-
// TODO: Use `getToolbarSrc()` once `@prismicio/client` adds `v=5`.
|
|
17
|
-
src: `${getToolbarSrc(repositoryName)}&v=5`,
|
|
18
|
-
// The toolbar builds share links with this URL. `next/script` adds `lazyOnload` scripts in
|
|
19
|
-
// the browser, where the URL is known.
|
|
20
|
-
"data-preview-url":
|
|
21
|
-
typeof window === "undefined" ? undefined : new URL(previewURL, document.baseURI).href,
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** Fetches the current ref of a preview session, for share links that only carry the session. */
|
|
26
|
-
export async function getPreviewSessionRef(
|
|
27
|
-
client: Pick<Client, "documentAPIEndpoint">,
|
|
28
|
-
session: string,
|
|
29
|
-
): Promise<string> {
|
|
30
|
-
const url = new URL(`/previews/token/${encodeURIComponent(session)}`, client.documentAPIEndpoint)
|
|
31
|
-
// The endpoint is on the repository host, not on its CDN.
|
|
32
|
-
url.hostname = url.hostname.replace(".cdn.", ".")
|
|
33
|
-
const res = await fetch(url, { cache: "no-store" })
|
|
34
|
-
const json = await res.json()
|
|
35
|
-
if (!json.ref) {
|
|
36
|
-
// Like the Content API's response to an expired preview token.
|
|
37
|
-
throw new PreviewTokenExpiredError("This preview session has expired", url.href, json)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return json.ref
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** Returns `path` if it is a path on the same origin, like `/blog?page=2`. */
|
|
44
|
-
export function getSafePath(path: string | undefined | null): string | undefined {
|
|
45
|
-
if (!path?.startsWith("/") || path.startsWith("//") || path.startsWith("/\\")) {
|
|
46
|
-
return
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const origin = "https://placeholder.invalid"
|
|
50
|
-
const url = new URL(path, origin)
|
|
51
|
-
if (url.origin === origin) {
|
|
52
|
-
return url.href.slice(origin.length)
|
|
53
|
-
}
|
|
54
|
-
}
|