UNPKG

next

Version:

The React Framework

5 lines 954 B
"use strict";exports.__esModule=true;exports.normalizePagePath=normalizePagePath;exports.denormalizePagePath=exports.normalizePathSep=void 0;var _path=require("path");var _denormalizePagePath=require("./denormalize-page-path");exports.normalizePathSep=_denormalizePagePath.normalizePathSep;exports.denormalizePagePath=_denormalizePagePath.denormalizePagePath;function normalizePagePath(page){// If the page is `/` we need to append `/index`, otherwise the returned directory root will be bundles instead of pages if(page==='/'){page='/index';}else if(/^\/index(\/|$)/.test(page)){page=`/index${page}`;}// Resolve on anything that doesn't start with `/` if(!page.startsWith('/')){page=`/${page}`;}// Throw when using ../ etc in the pathname const resolvedPage=_path.posix.normalize(page);if(page!==resolvedPage){throw new Error(`Requested and resolved page mismatch: ${page} ${resolvedPage}`);}return page;} //# sourceMappingURL=normalize-page-path.js.map