generated from allen-cell-animated/github-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathreroute.bundle.js.map
1 lines (1 loc) · 6.52 KB
/
reroute.bundle.js.map
1
{"version":3,"file":"reroute.bundle.js","mappings":"mBAAA,IAAMA,EAAoB,QAyBnB,SAASC,EAA2BC,GAA6C,IAAnCC,EAAwBC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,EACxEG,EAAeL,EAAIM,SAASC,MAAM,KAClCC,EAAWH,EAAaI,MAAM,EAAGR,EAAmB,GAAGS,KAAK,KAI5DC,EAHgBN,EAAaI,MAAMR,EAAmB,GAAGS,KAAK,KAGpCE,QAAQ,KAAMd,GACxCe,EAAcb,EAAIc,OAASd,EAAIc,OAAOL,MAAM,GAAGG,QAAQ,KAAMd,GAAqB,GAEpFiB,EAAS,GAAHC,OAAMhB,EAAIiB,QAAMD,OAAGR,EAAQ,OAAAQ,OAAML,GAI3C,OAHAI,GAAUF,EAAc,IAAHG,OAAOH,GAAgB,GAC5CE,GAAUf,EAAIkB,KAEP,IAAIC,IAAIJ,EACjB,CCnCAK,OAAOC,OAAS,WACdC,SAASC,KAAKC,UAAY,EAC5B,EAIA,ID6DqCxB,EC7D/ByB,EAAWL,OAAOK,SAElBV,GD2D+Bf,EC5DjB,IAAImB,IAAIM,EAASC,YD8Dd,mCADrB1B,EAAM,IAAImB,IAAInB,IACN2B,SACF3B,EAAIM,SAASoB,WAAWE,SAAS,cAC5B7B,EAA2BC,EAAK,IAGrCA,EAAIM,SAASoB,WAAWE,SAAS,UACnC5B,EAAIM,SAAWN,EAAIM,SAASM,QAAQ,QAAS,KAExCb,EAA2BC,EAAK,IAGlCA,GCvETyB,EAASb,QAAQG,GACjBc,QAAQC,IAAI,kBAAoBf,EAAOW,W","sources":["webpack://@aics/vole-app/./website/utils/gh_route_utils.ts","webpack://@aics/vole-app/./public/gh-reroute/index.tsx"],"sourcesContent":["const ESCAPED_AMPERSAND = \"~and~\";\n\n/**\n * Encodes the path component of a URL into a query string. Used to redirect the browser\n * for single-page apps when the server is not configured to serve the app for all paths,\n * e.g. GitHub pages.\n *\n * Adapted from https://github.com/rafgraph/spa-github-pages.\n *\n * The original path will be converted into a query string, and the original query string will be\n * escaped and separated with an `&` character.\n *\n * @example\n * ```\n * const url = \"https://www.example.com/one/two?a=b&c=d#qwe\";\n * // Original: \"https://www.example.com/one/two?a=b&c=d#qwe\"\n * convertUrlToQueryStringPath(url, 0); // => \"https://www.example.com/?/one/two&a=b~and~c=d#qwe\"\n * convertUrlToQueryStringPath(url, 1); // => \"https://www.example.com/one/?/two&a=b~and~c=d#qwe\"\n * ```\n *\n * @param url - The URL to convert.\n * @param basePathSegments - The number of path segments to keep in the URL. 0 by default.\n *\n * @returns The URL with the path converted to a query string, and the original query string escaped.\n */\nexport function encodeUrlPathAsQueryString(url: URL, basePathSegments: number = 0): URL {\n const pathSegments = url.pathname.split(\"/\");\n const basePath = pathSegments.slice(0, basePathSegments + 1).join(\"/\");\n const remainingPath = pathSegments.slice(basePathSegments + 1).join(\"/\");\n // Remove the \"?\" and replace with an \"&\" to separate the path from the original query string.\n // Escape existing ampersands with \"~and~\" so \"&\" is preserved as our path/query separator.\n const queryPath = remainingPath.replace(/&/g, ESCAPED_AMPERSAND);\n const queryString = url.search ? url.search.slice(1).replace(/&/g, ESCAPED_AMPERSAND) : \"\";\n\n let newUrl = `${url.origin}${basePath}/?/${queryPath}`;\n newUrl += queryString ? `&${queryString}` : \"\";\n newUrl += url.hash;\n\n return new URL(newUrl);\n}\n\n/**\n * Converts a query string back into a complete URL. Used in combination with `convertUrlToQueryStringPath()`.\n * to redirect the browser for single-page apps when the server cannot be configured, e.g. GitHub pages.\n * Adapted from https://github.com/rafgraph/spa-github-pages.\n *\n * @param url - The URL with a path converted to a query string, and the original query string escaped.\n * @returns The original URL, with path instead of a query string.\n */\nexport function decodeUrlQueryStringPath(url: URL): URL {\n if (!url.search || !url.search.startsWith(\"?/\")) {\n return url;\n }\n\n const newPathAndQueryString = url.search\n .slice(2) // Remove first ? character and slash\n .split(\"&\") // Split the original path [idx 0] and query string [idx 1]\n .map((s) => s.replace(new RegExp(ESCAPED_AMPERSAND, \"g\"), \"&\")) // Restore escaped ampersands\n .join(\"?\"); // Rejoin the path and query string\n\n return new URL(`${url.origin}${url.pathname}${newPathAndQueryString}${url.hash}`);\n}\n\nexport function isEncodedPathUrl(url: URL): boolean {\n return url.search !== \"\" && url.search.startsWith(\"?/\");\n}\n\n/**\n * Encodes a URL for GitHub pages by converting the path to a query string.\n * See `encodeUrlPathAsQueryString()` for more details.\n */\nexport function encodeGitHubPagesUrl(url: URL): URL {\n url = new URL(url); // Clone the URL to avoid modifying the original\n if (url.hostname === \"allen-cell-animated.github.io\") {\n if (url.pathname.toString().includes(\"pr-preview\")) {\n return encodeUrlPathAsQueryString(url, 3);\n }\n // Redirect `/main` paths back to root `/`\n if (url.pathname.toString().includes(\"main\")) {\n url.pathname = url.pathname.replace(\"/main\", \"\");\n }\n return encodeUrlPathAsQueryString(url, 1);\n }\n\n return url;\n}\n\n/**\n * Decodes a URL that was encoded for GitHub pages, e.g. by `encodeGitHubPagesUrl()`.\n * See `decodeUrlQueryStringPath()` for more details.\n */\nexport function decodeGitHubPagesUrl(url: URL): URL {\n return decodeUrlQueryStringPath(url);\n}\n\n/**\n * Changes URLs with hash-based routing to path-based routing by removing the hash from\n * the URL. Does nothing to URLs that do not use hash-based routing.\n */\nexport function tryRemoveHashRouting(url: URL): URL {\n // Remove #/ from the URL path\n if (url.hash.startsWith(\"#/\")) {\n const hashContents = url.hash.slice(2);\n const [path, queryParams] = hashContents.split(\"?\");\n url.pathname += path;\n url.search = queryParams ? `?${queryParams}` : \"\";\n url.hash = \"\";\n }\n return url;\n}\n","import { encodeGitHubPagesUrl } from \"../../website/utils/gh_route_utils\";\n\n// Hide the default 404 page content and just show a blank screen.\n// The content should only be shown if the browser doesn't support JavaScript.\nwindow.onload = () => {\n document.body.innerHTML = \"\";\n};\n\n// This script is used in the 404.html page to redirect the browser to the correct URL.\n// Convert the current URL to a query string path and redirect the browser.\nconst location = window.location;\nconst locationUrl = new URL(location.toString());\nconst newUrl = encodeGitHubPagesUrl(locationUrl);\nlocation.replace(newUrl);\nconsole.log(\"Redirecting to \" + newUrl.toString());\n"],"names":["ESCAPED_AMPERSAND","encodeUrlPathAsQueryString","url","basePathSegments","arguments","length","undefined","pathSegments","pathname","split","basePath","slice","join","queryPath","replace","queryString","search","newUrl","concat","origin","hash","URL","window","onload","document","body","innerHTML","location","toString","hostname","includes","console","log"],"sourceRoot":""}