@b9g/match-pattern 0.1.3 → 0.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@b9g/match-pattern",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "devDependencies": {
5
5
  "@b9g/libuild": "^0.1.10"
6
6
  },
@@ -13,21 +13,9 @@
13
13
  }
14
14
  },
15
15
  "type": "module",
16
- "types": "src/index.d.ts",
17
- "module": "src/index.js",
16
+ "types": "src/match-pattern.d.ts",
17
+ "module": "src/match-pattern.js",
18
18
  "exports": {
19
- ".": {
20
- "types": "./src/index.d.ts",
21
- "import": "./src/index.js"
22
- },
23
- "./index": {
24
- "types": "./src/index.d.ts",
25
- "import": "./src/index.js"
26
- },
27
- "./index.js": {
28
- "types": "./src/index.d.ts",
29
- "import": "./src/index.js"
30
- },
31
19
  "./match-pattern": {
32
20
  "types": "./src/match-pattern.d.ts",
33
21
  "import": "./src/match-pattern.js"
@@ -36,6 +24,10 @@
36
24
  "types": "./src/match-pattern.d.ts",
37
25
  "import": "./src/match-pattern.js"
38
26
  },
39
- "./package.json": "./package.json"
27
+ "./package.json": "./package.json",
28
+ ".": {
29
+ "types": "./src/match-pattern.d.ts",
30
+ "import": "./src/match-pattern.js"
31
+ }
40
32
  }
41
33
  }
@@ -32,11 +32,11 @@ export declare class MatchPattern extends URLPattern {
32
32
  private _originalInput;
33
33
  constructor(input: string | URLPatternInit, baseURL?: string);
34
34
  /**
35
- * Enhanced exec that returns unified params object with trailing slash normalization
35
+ * Enhanced exec that returns unified params object
36
36
  */
37
37
  exec(input: string | URL): MatchPatternResult | null;
38
38
  /**
39
- * Enhanced test with order-independent search parameter matching and trailing slash normalization
39
+ * Enhanced test with order-independent search parameter matching
40
40
  */
41
41
  test(input: string | URL): boolean;
42
42
  }
@@ -12,47 +12,41 @@ var MatchPattern = class extends URLPattern {
12
12
  if (typeof input === "string") {
13
13
  processedInput = parseStringPattern(input);
14
14
  }
15
- const normalizedInput = normalizePatternTrailingSlash(processedInput);
16
15
  if (baseURL !== void 0) {
17
- super(normalizedInput, baseURL);
16
+ super(processedInput, baseURL);
18
17
  } else {
19
- super(normalizedInput);
18
+ super(processedInput);
20
19
  }
21
- this._originalInput = normalizedInput;
20
+ this._originalInput = processedInput;
22
21
  }
23
22
  /**
24
- * Enhanced exec that returns unified params object with trailing slash normalization
23
+ * Enhanced exec that returns unified params object
25
24
  */
26
25
  exec(input) {
27
26
  if (!this.test(input)) {
28
27
  return null;
29
28
  }
30
- const url = typeof input === "string" ? new URL(input) : input;
31
- const normalizedUrl = normalizeTrailingSlash(url);
32
- const result = super.exec(normalizedUrl);
29
+ const result = super.exec(input);
33
30
  if (result) {
34
31
  const enhancedResult = {
35
32
  ...result,
36
33
  params: extractUnifiedParams(result, input)
37
- // Use original input for search params
38
34
  };
39
35
  return enhancedResult;
40
36
  }
41
37
  return buildCustomResult(this, input);
42
38
  }
43
39
  /**
44
- * Enhanced test with order-independent search parameter matching and trailing slash normalization
40
+ * Enhanced test with order-independent search parameter matching
45
41
  */
46
42
  test(input) {
47
43
  const url = typeof input === "string" ? new URL(input) : input;
48
- const normalizedUrl = normalizeTrailingSlash(url);
49
44
  if (!this.search || this.search === "*") {
50
- return super.test(normalizedUrl);
45
+ return super.test(input);
51
46
  }
52
47
  const pathPatternInit = typeof this._originalInput === "string" ? { pathname: this._originalInput } : { ...this._originalInput, search: void 0 };
53
- const normalizedPattern = normalizePatternTrailingSlash(pathPatternInit);
54
- const pathPattern = new URLPattern(normalizedPattern);
55
- if (!pathPattern.test(normalizedUrl)) {
48
+ const pathPattern = new URLPattern(pathPatternInit);
49
+ if (!pathPattern.test(input)) {
56
50
  return false;
57
51
  }
58
52
  return testSearchParameters(this.search, url.searchParams);
@@ -113,31 +107,6 @@ function extractUnifiedParams(result, url) {
113
107
  }
114
108
  return params;
115
109
  }
116
- function normalizeTrailingSlash(url) {
117
- const normalized = new URL(url.href);
118
- if (normalized.pathname === "/") {
119
- return normalized;
120
- }
121
- if (normalized.pathname.endsWith("/")) {
122
- normalized.pathname = normalized.pathname.slice(0, -1);
123
- }
124
- return normalized;
125
- }
126
- function normalizePatternTrailingSlash(patternInit) {
127
- if (typeof patternInit === "string") {
128
- if (patternInit === "/" || patternInit === "") {
129
- return patternInit;
130
- }
131
- return patternInit.endsWith("/") ? patternInit.slice(0, -1) : patternInit;
132
- }
133
- const normalized = { ...patternInit };
134
- if (normalized.pathname && normalized.pathname !== "/") {
135
- if (normalized.pathname.endsWith("/")) {
136
- normalized.pathname = normalized.pathname.slice(0, -1);
137
- }
138
- }
139
- return normalized;
140
- }
141
110
  function buildCustomResult(pattern, input) {
142
111
  const url = typeof input === "string" ? new URL(input) : input;
143
112
  const result = {
package/src/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export { MatchPattern, type MatchPatternResult } from "./match-pattern.ts";
package/src/index.js DELETED
@@ -1,6 +0,0 @@
1
- /// <reference types="./index.d.ts" />
2
- // src/index.ts
3
- import { MatchPattern } from "./match-pattern.js";
4
- export {
5
- MatchPattern
6
- };