This commit is contained in:
Kismet Hasanaj
2026-05-02 20:07:02 +02:00
parent ce8672e283
commit 34dc9aec52
9428 changed files with 1733330 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
import type { PathnameNormalizer } from './pathname-normalizer';
import { PrefixPathnameNormalizer } from './prefix';
export declare class BasePathPathnameNormalizer extends PrefixPathnameNormalizer implements PathnameNormalizer {
constructor(basePath: string);
}
+25
View File
@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "BasePathPathnameNormalizer", {
enumerable: true,
get: function() {
return BasePathPathnameNormalizer;
}
});
const _prefix = require("./prefix");
class BasePathPathnameNormalizer extends _prefix.PrefixPathnameNormalizer {
constructor(basePath){
if (!basePath || basePath === '/') {
throw Object.defineProperty(new Error('Invariant: basePath must be set and cannot be "/"'), "__NEXT_ERROR_CODE", {
value: "E154",
enumerable: false,
configurable: true
});
}
super(basePath);
}
}
//# sourceMappingURL=base-path.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/normalizers/request/base-path.ts"],"sourcesContent":["import type { PathnameNormalizer } from './pathname-normalizer'\n\nimport { PrefixPathnameNormalizer } from './prefix'\n\nexport class BasePathPathnameNormalizer\n extends PrefixPathnameNormalizer\n implements PathnameNormalizer\n{\n constructor(basePath: string) {\n if (!basePath || basePath === '/') {\n throw new Error('Invariant: basePath must be set and cannot be \"/\"')\n }\n\n super(basePath)\n }\n}\n"],"names":["BasePathPathnameNormalizer","PrefixPathnameNormalizer","constructor","basePath","Error"],"mappings":";;;;+BAIaA;;;eAAAA;;;wBAF4B;AAElC,MAAMA,mCACHC,gCAAwB;IAGhCC,YAAYC,QAAgB,CAAE;QAC5B,IAAI,CAACA,YAAYA,aAAa,KAAK;YACjC,MAAM,qBAA8D,CAA9D,IAAIC,MAAM,sDAAV,qBAAA;uBAAA;4BAAA;8BAAA;YAA6D;QACrE;QAEA,KAAK,CAACD;IACR;AACF","ignoreList":[0]}
+8
View File
@@ -0,0 +1,8 @@
import type { PathnameNormalizer } from './pathname-normalizer';
export declare class NextDataPathnameNormalizer implements PathnameNormalizer {
private readonly prefix;
private readonly suffix;
constructor(buildID: string);
match(pathname: string): boolean;
normalize(pathname: string, matched?: boolean): string;
}
+38
View File
@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "NextDataPathnameNormalizer", {
enumerable: true,
get: function() {
return NextDataPathnameNormalizer;
}
});
const _denormalizepagepath = require("../../../shared/lib/page-path/denormalize-page-path");
const _prefix = require("./prefix");
const _suffix = require("./suffix");
class NextDataPathnameNormalizer {
constructor(buildID){
this.suffix = new _suffix.SuffixPathnameNormalizer('.json');
if (!buildID) {
throw Object.defineProperty(new Error('Invariant: buildID is required'), "__NEXT_ERROR_CODE", {
value: "E200",
enumerable: false,
configurable: true
});
}
this.prefix = new _prefix.PrefixPathnameNormalizer(`/_next/data/${buildID}`);
}
match(pathname) {
return this.prefix.match(pathname) && this.suffix.match(pathname);
}
normalize(pathname, matched) {
// If we're not matched and we don't match, we don't need to normalize.
if (!matched && !this.match(pathname)) return pathname;
pathname = this.prefix.normalize(pathname, true);
pathname = this.suffix.normalize(pathname, true);
return (0, _denormalizepagepath.denormalizePagePath)(pathname);
}
}
//# sourceMappingURL=next-data.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/normalizers/request/next-data.ts"],"sourcesContent":["import type { PathnameNormalizer } from './pathname-normalizer'\n\nimport { denormalizePagePath } from '../../../shared/lib/page-path/denormalize-page-path'\nimport { PrefixPathnameNormalizer } from './prefix'\nimport { SuffixPathnameNormalizer } from './suffix'\n\nexport class NextDataPathnameNormalizer implements PathnameNormalizer {\n private readonly prefix: PrefixPathnameNormalizer\n private readonly suffix = new SuffixPathnameNormalizer('.json')\n constructor(buildID: string) {\n if (!buildID) {\n throw new Error('Invariant: buildID is required')\n }\n\n this.prefix = new PrefixPathnameNormalizer(`/_next/data/${buildID}`)\n }\n\n public match(pathname: string) {\n return this.prefix.match(pathname) && this.suffix.match(pathname)\n }\n\n public normalize(pathname: string, matched?: boolean): string {\n // If we're not matched and we don't match, we don't need to normalize.\n if (!matched && !this.match(pathname)) return pathname\n\n pathname = this.prefix.normalize(pathname, true)\n pathname = this.suffix.normalize(pathname, true)\n\n return denormalizePagePath(pathname)\n }\n}\n"],"names":["NextDataPathnameNormalizer","constructor","buildID","suffix","SuffixPathnameNormalizer","Error","prefix","PrefixPathnameNormalizer","match","pathname","normalize","matched","denormalizePagePath"],"mappings":";;;;+BAMaA;;;eAAAA;;;qCAJuB;wBACK;wBACA;AAElC,MAAMA;IAGXC,YAAYC,OAAe,CAAE;aADZC,SAAS,IAAIC,gCAAwB,CAAC;QAErD,IAAI,CAACF,SAAS;YACZ,MAAM,qBAA2C,CAA3C,IAAIG,MAAM,mCAAV,qBAAA;uBAAA;4BAAA;8BAAA;YAA0C;QAClD;QAEA,IAAI,CAACC,MAAM,GAAG,IAAIC,gCAAwB,CAAC,CAAC,YAAY,EAAEL,SAAS;IACrE;IAEOM,MAAMC,QAAgB,EAAE;QAC7B,OAAO,IAAI,CAACH,MAAM,CAACE,KAAK,CAACC,aAAa,IAAI,CAACN,MAAM,CAACK,KAAK,CAACC;IAC1D;IAEOC,UAAUD,QAAgB,EAAEE,OAAiB,EAAU;QAC5D,uEAAuE;QACvE,IAAI,CAACA,WAAW,CAAC,IAAI,CAACH,KAAK,CAACC,WAAW,OAAOA;QAE9CA,WAAW,IAAI,CAACH,MAAM,CAACI,SAAS,CAACD,UAAU;QAC3CA,WAAW,IAAI,CAACN,MAAM,CAACO,SAAS,CAACD,UAAU;QAE3C,OAAOG,IAAAA,wCAAmB,EAACH;IAC7B;AACF","ignoreList":[0]}
@@ -0,0 +1,5 @@
import type { Normalizer } from '../normalizer';
export interface PathnameNormalizer extends Normalizer {
match(pathname: string): boolean;
normalize(pathname: string, matched?: boolean): string;
}
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=pathname-normalizer.js.map
@@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","ignoreList":[]}
+7
View File
@@ -0,0 +1,7 @@
import type { Normalizer } from '../normalizer';
export declare class PrefixPathnameNormalizer implements Normalizer {
private readonly prefix;
constructor(prefix: string);
match(pathname: string): boolean;
normalize(pathname: string, matched?: boolean): string;
}
+39
View File
@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "PrefixPathnameNormalizer", {
enumerable: true,
get: function() {
return PrefixPathnameNormalizer;
}
});
class PrefixPathnameNormalizer {
constructor(prefix){
this.prefix = prefix;
if (prefix.endsWith('/')) {
throw Object.defineProperty(new Error(`PrefixPathnameNormalizer: prefix "${prefix}" should not end with a slash`), "__NEXT_ERROR_CODE", {
value: "E219",
enumerable: false,
configurable: true
});
}
}
match(pathname) {
// If the pathname doesn't start with the prefix, we don't match.
if (pathname !== this.prefix && !pathname.startsWith(this.prefix + '/')) {
return false;
}
return true;
}
normalize(pathname, matched) {
// If we're not matched and we don't match, we don't need to normalize.
if (!matched && !this.match(pathname)) return pathname;
if (pathname.length === this.prefix.length) {
return '/';
}
return pathname.substring(this.prefix.length);
}
}
//# sourceMappingURL=prefix.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/normalizers/request/prefix.ts"],"sourcesContent":["import type { Normalizer } from '../normalizer'\n\nexport class PrefixPathnameNormalizer implements Normalizer {\n constructor(private readonly prefix: string) {\n if (prefix.endsWith('/')) {\n throw new Error(\n `PrefixPathnameNormalizer: prefix \"${prefix}\" should not end with a slash`\n )\n }\n }\n\n public match(pathname: string) {\n // If the pathname doesn't start with the prefix, we don't match.\n if (pathname !== this.prefix && !pathname.startsWith(this.prefix + '/')) {\n return false\n }\n\n return true\n }\n\n public normalize(pathname: string, matched?: boolean): string {\n // If we're not matched and we don't match, we don't need to normalize.\n if (!matched && !this.match(pathname)) return pathname\n\n if (pathname.length === this.prefix.length) {\n return '/'\n }\n\n return pathname.substring(this.prefix.length)\n }\n}\n"],"names":["PrefixPathnameNormalizer","constructor","prefix","endsWith","Error","match","pathname","startsWith","normalize","matched","length","substring"],"mappings":";;;;+BAEaA;;;eAAAA;;;AAAN,MAAMA;IACXC,YAAY,AAAiBC,MAAc,CAAE;aAAhBA,SAAAA;QAC3B,IAAIA,OAAOC,QAAQ,CAAC,MAAM;YACxB,MAAM,qBAEL,CAFK,IAAIC,MACR,CAAC,kCAAkC,EAAEF,OAAO,6BAA6B,CAAC,GADtE,qBAAA;uBAAA;4BAAA;8BAAA;YAEN;QACF;IACF;IAEOG,MAAMC,QAAgB,EAAE;QAC7B,iEAAiE;QACjE,IAAIA,aAAa,IAAI,CAACJ,MAAM,IAAI,CAACI,SAASC,UAAU,CAAC,IAAI,CAACL,MAAM,GAAG,MAAM;YACvE,OAAO;QACT;QAEA,OAAO;IACT;IAEOM,UAAUF,QAAgB,EAAEG,OAAiB,EAAU;QAC5D,uEAAuE;QACvE,IAAI,CAACA,WAAW,CAAC,IAAI,CAACJ,KAAK,CAACC,WAAW,OAAOA;QAE9C,IAAIA,SAASI,MAAM,KAAK,IAAI,CAACR,MAAM,CAACQ,MAAM,EAAE;YAC1C,OAAO;QACT;QAEA,OAAOJ,SAASK,SAAS,CAAC,IAAI,CAACT,MAAM,CAACQ,MAAM;IAC9C;AACF","ignoreList":[0]}
+5
View File
@@ -0,0 +1,5 @@
import type { PathnameNormalizer } from './pathname-normalizer';
import { SuffixPathnameNormalizer } from './suffix';
export declare class RSCPathnameNormalizer extends SuffixPathnameNormalizer implements PathnameNormalizer {
constructor();
}
+19
View File
@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "RSCPathnameNormalizer", {
enumerable: true,
get: function() {
return RSCPathnameNormalizer;
}
});
const _constants = require("../../../lib/constants");
const _suffix = require("./suffix");
class RSCPathnameNormalizer extends _suffix.SuffixPathnameNormalizer {
constructor(){
super(_constants.RSC_SUFFIX);
}
}
//# sourceMappingURL=rsc.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/normalizers/request/rsc.ts"],"sourcesContent":["import type { PathnameNormalizer } from './pathname-normalizer'\n\nimport { RSC_SUFFIX } from '../../../lib/constants'\nimport { SuffixPathnameNormalizer } from './suffix'\n\nexport class RSCPathnameNormalizer\n extends SuffixPathnameNormalizer\n implements PathnameNormalizer\n{\n constructor() {\n super(RSC_SUFFIX)\n }\n}\n"],"names":["RSCPathnameNormalizer","SuffixPathnameNormalizer","constructor","RSC_SUFFIX"],"mappings":";;;;+BAKaA;;;eAAAA;;;2BAHc;wBACc;AAElC,MAAMA,8BACHC,gCAAwB;IAGhCC,aAAc;QACZ,KAAK,CAACC,qBAAU;IAClB;AACF","ignoreList":[0]}
@@ -0,0 +1,9 @@
import type { PathnameNormalizer } from './pathname-normalizer';
export declare class SegmentPrefixRSCPathnameNormalizer implements PathnameNormalizer {
match(pathname: string): boolean;
extract(pathname: string): {
originalPathname: string;
segmentPath: string;
} | null;
normalize(pathname: string): string;
}
@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "SegmentPrefixRSCPathnameNormalizer", {
enumerable: true,
get: function() {
return SegmentPrefixRSCPathnameNormalizer;
}
});
const _constants = require("../../../lib/constants");
const _escaperegexp = require("../../../shared/lib/escape-regexp");
const PATTERN = new RegExp(`^(/.*)${(0, _escaperegexp.escapeStringRegexp)(_constants.RSC_SEGMENTS_DIR_SUFFIX)}(/.*)${(0, _escaperegexp.escapeStringRegexp)(_constants.RSC_SEGMENT_SUFFIX)}$`);
class SegmentPrefixRSCPathnameNormalizer {
match(pathname) {
return PATTERN.test(pathname);
}
extract(pathname) {
const match = pathname.match(PATTERN);
if (!match) return null;
return {
originalPathname: match[1],
segmentPath: match[2]
};
}
normalize(pathname) {
const match = this.extract(pathname);
if (!match) return pathname;
return match.originalPathname;
}
}
//# sourceMappingURL=segment-prefix-rsc.js.map
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/normalizers/request/segment-prefix-rsc.ts"],"sourcesContent":["import type { PathnameNormalizer } from './pathname-normalizer'\n\nimport {\n RSC_SEGMENT_SUFFIX,\n RSC_SEGMENTS_DIR_SUFFIX,\n} from '../../../lib/constants'\nimport { escapeStringRegexp } from '../../../shared/lib/escape-regexp'\n\nconst PATTERN = new RegExp(\n `^(/.*)${escapeStringRegexp(RSC_SEGMENTS_DIR_SUFFIX)}(/.*)${escapeStringRegexp(RSC_SEGMENT_SUFFIX)}$`\n)\n\nexport class SegmentPrefixRSCPathnameNormalizer implements PathnameNormalizer {\n public match(pathname: string): boolean {\n return PATTERN.test(pathname)\n }\n\n public extract(pathname: string) {\n const match = pathname.match(PATTERN)\n if (!match) return null\n\n return { originalPathname: match[1], segmentPath: match[2] }\n }\n\n public normalize(pathname: string): string {\n const match = this.extract(pathname)\n if (!match) return pathname\n\n return match.originalPathname\n }\n}\n"],"names":["SegmentPrefixRSCPathnameNormalizer","PATTERN","RegExp","escapeStringRegexp","RSC_SEGMENTS_DIR_SUFFIX","RSC_SEGMENT_SUFFIX","match","pathname","test","extract","originalPathname","segmentPath","normalize"],"mappings":";;;;+BAYaA;;;eAAAA;;;2BAPN;8BAC4B;AAEnC,MAAMC,UAAU,IAAIC,OAClB,CAAC,MAAM,EAAEC,IAAAA,gCAAkB,EAACC,kCAAuB,EAAE,KAAK,EAAED,IAAAA,gCAAkB,EAACE,6BAAkB,EAAE,CAAC,CAAC;AAGhG,MAAML;IACJM,MAAMC,QAAgB,EAAW;QACtC,OAAON,QAAQO,IAAI,CAACD;IACtB;IAEOE,QAAQF,QAAgB,EAAE;QAC/B,MAAMD,QAAQC,SAASD,KAAK,CAACL;QAC7B,IAAI,CAACK,OAAO,OAAO;QAEnB,OAAO;YAAEI,kBAAkBJ,KAAK,CAAC,EAAE;YAAEK,aAAaL,KAAK,CAAC,EAAE;QAAC;IAC7D;IAEOM,UAAUL,QAAgB,EAAU;QACzC,MAAMD,QAAQ,IAAI,CAACG,OAAO,CAACF;QAC3B,IAAI,CAACD,OAAO,OAAOC;QAEnB,OAAOD,MAAMI,gBAAgB;IAC/B;AACF","ignoreList":[0]}
+7
View File
@@ -0,0 +1,7 @@
import type { Normalizer } from '../normalizer';
export declare class SuffixPathnameNormalizer implements Normalizer {
private readonly suffix;
constructor(suffix: string);
match(pathname: string): boolean;
normalize(pathname: string, matched?: boolean): string;
}
+27
View File
@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "SuffixPathnameNormalizer", {
enumerable: true,
get: function() {
return SuffixPathnameNormalizer;
}
});
class SuffixPathnameNormalizer {
constructor(suffix){
this.suffix = suffix;
}
match(pathname) {
// If the pathname doesn't end in the suffix, we don't match.
if (!pathname.endsWith(this.suffix)) return false;
return true;
}
normalize(pathname, matched) {
// If we're not matched and we don't match, we don't need to normalize.
if (!matched && !this.match(pathname)) return pathname;
return pathname.substring(0, pathname.length - this.suffix.length);
}
}
//# sourceMappingURL=suffix.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/normalizers/request/suffix.ts"],"sourcesContent":["import type { Normalizer } from '../normalizer'\n\nexport class SuffixPathnameNormalizer implements Normalizer {\n constructor(private readonly suffix: string) {}\n\n public match(pathname: string) {\n // If the pathname doesn't end in the suffix, we don't match.\n if (!pathname.endsWith(this.suffix)) return false\n\n return true\n }\n\n public normalize(pathname: string, matched?: boolean): string {\n // If we're not matched and we don't match, we don't need to normalize.\n if (!matched && !this.match(pathname)) return pathname\n\n return pathname.substring(0, pathname.length - this.suffix.length)\n }\n}\n"],"names":["SuffixPathnameNormalizer","constructor","suffix","match","pathname","endsWith","normalize","matched","substring","length"],"mappings":";;;;+BAEaA;;;eAAAA;;;AAAN,MAAMA;IACXC,YAAY,AAAiBC,MAAc,CAAE;aAAhBA,SAAAA;IAAiB;IAEvCC,MAAMC,QAAgB,EAAE;QAC7B,6DAA6D;QAC7D,IAAI,CAACA,SAASC,QAAQ,CAAC,IAAI,CAACH,MAAM,GAAG,OAAO;QAE5C,OAAO;IACT;IAEOI,UAAUF,QAAgB,EAAEG,OAAiB,EAAU;QAC5D,uEAAuE;QACvE,IAAI,CAACA,WAAW,CAAC,IAAI,CAACJ,KAAK,CAACC,WAAW,OAAOA;QAE9C,OAAOA,SAASI,SAAS,CAAC,GAAGJ,SAASK,MAAM,GAAG,IAAI,CAACP,MAAM,CAACO,MAAM;IACnE;AACF","ignoreList":[0]}