infinity-forge
Version:
23 lines • 1.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPathnameRef = getPathnameRef;
var generate_ref_1 = require("./generate_ref.js");
function getPathnameRef(props) {
var _a, _b, _c;
var pathname = ((_a = props === null || props === void 0 ? void 0 : props.router) === null || _a === void 0 ? void 0 : _a.asPath) || ((_c = (_b = props === null || props === void 0 ? void 0 : props.context) === null || _b === void 0 ? void 0 : _b.router) === null || _c === void 0 ? void 0 : _c.asPath) || (props === null || props === void 0 ? void 0 : props.pageUrl);
if (pathname === null || pathname === void 0 ? void 0 : pathname.includes('#')) {
pathname = pathname.split('#')[0];
}
if (pathname === null || pathname === void 0 ? void 0 : pathname.includes("?")) {
pathname = pathname.split("?")[0];
}
if (pathname === '/' || !pathname) {
return { page: 'home' };
}
if (pathname[0].includes("/")) {
pathname = pathname.replace("/", "");
}
var parts = pathname.split('/');
return { page: (0, generate_ref_1.normalizeString)(parts[0]) };
}
//# sourceMappingURL=get-pathname-ref.js.map