quasiurl 1.1.1 → 1.1.3

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/dist/index.js CHANGED
@@ -13,14 +13,12 @@ var QuasiURL = class {
13
13
  return `${this.origin}${this.pathname}${this.search}${this.hash}`;
14
14
  }
15
15
  set href(value) {
16
- let head = value.match(/^((\w+:)?\/\/([^/:]+)(:(\d+))?)(\/.*|$)/);
17
- let tail = value.match(/(\?[^#]+)?(#.+)?$/);
18
- this.protocol = head?.[2] ?? "";
19
- this.hostname = head?.[3] ?? "";
20
- this.port = head?.[5] ?? "";
21
- this.pathname = value.replace(/^(\w+:)?\/\/[^/:]+(:\d+)?/, "").replace(/\?.*$/, "").replace(/#.*$/, "");
22
- this.search = tail?.[1] ?? "";
23
- this.hash = tail?.[2] ?? "";
16
+ let origin = value.match(/^(\w+:)?\/\/[^/:]+(:\d+)?/)?.[0] ?? "";
17
+ let tail = value.slice(origin.length).match(/^([^?#]+)?(\?[^#]+)?(#.+)?$/) ?? [];
18
+ this.origin = origin;
19
+ this.pathname = tail[1] ?? "";
20
+ this.search = tail[2] ?? "";
21
+ this.hash = tail[3] ?? "";
24
22
  }
25
23
  get protocol() {
26
24
  return this._protocol;
package/index.ts CHANGED
@@ -17,18 +17,14 @@ export class QuasiURL {
17
17
  return `${this.origin}${this.pathname}${this.search}${this.hash}`;
18
18
  }
19
19
  set href(value: string) {
20
- let head = value.match(/^((\w+:)?\/\/([^/:]+)(:(\d+))?)(\/.*|$)/);
21
- let tail = value.match(/(\?[^#]+)?(#.+)?$/);
20
+ let origin = value.match(/^(\w+:)?\/\/[^/:]+(:\d+)?/)?.[0] ?? "";
21
+ let tail =
22
+ value.slice(origin.length).match(/^([^?#]+)?(\?[^#]+)?(#.+)?$/) ?? [];
22
23
 
23
- this.protocol = head?.[2] ?? "";
24
- this.hostname = head?.[3] ?? "";
25
- this.port = head?.[5] ?? "";
26
- this.pathname = value
27
- .replace(/^(\w+:)?\/\/[^/:]+(:\d+)?/, "")
28
- .replace(/\?.*$/, "")
29
- .replace(/#.*$/, "");
30
- this.search = tail?.[1] ?? "";
31
- this.hash = tail?.[2] ?? "";
24
+ this.origin = origin;
25
+ this.pathname = tail[1] ?? "";
26
+ this.search = tail[2] ?? "";
27
+ this.hash = tail[3] ?? "";
32
28
  }
33
29
  get protocol() {
34
30
  return this._protocol;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quasiurl",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "URL for templating",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/tsconfig.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
- "include": ["index.ts", "tests.ts"],
2
+ "include": ["./index.ts", "./tests.ts"],
3
3
  "compilerOptions": {
4
+ "noEmit": true,
4
5
  "lib": ["ESNext", "DOM"],
5
- "target": "ESNext",
6
+ "target": "esnext",
6
7
  "outDir": "dist",
7
- "moduleResolution": "node",
8
+ "module": "nodenext",
9
+ "moduleResolution": "nodenext",
10
+ "allowImportingTsExtensions": true,
8
11
  "strict": true,
9
12
  "noUnusedLocals": true,
10
13
  "noUnusedParameters": true