@scalar/helpers 0.0.10 → 0.0.11

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @scalar/helpers
2
2
 
3
+ ## 0.0.11
4
+
5
+ ### Patch Changes
6
+
7
+ - bff46e5: feat: don’t use proxy for reserved tlds
8
+
3
9
  ## 0.0.10
4
10
 
5
11
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Detect requests to localhost
2
+ * Detect requests to localhost or reserved TLDs
3
3
  */
4
4
  export declare function isLocalUrl(url: string): boolean;
5
5
  //# sourceMappingURL=is-local-url.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-local-url.d.ts","sourceRoot":"","sources":["../../src/url/is-local-url.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,WAUrC"}
1
+ {"version":3,"file":"is-local-url.d.ts","sourceRoot":"","sources":["../../src/url/is-local-url.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,WAqBrC"}
@@ -1,8 +1,16 @@
1
1
  const LOCAL_HOSTNAMES = ["localhost", "127.0.0.1", "[::1]", "0.0.0.0"];
2
+ const RESERVED_TLDS = ["test", "example", "invalid", "localhost"];
2
3
  function isLocalUrl(url) {
3
4
  try {
4
5
  const { hostname } = new URL(url);
5
- return LOCAL_HOSTNAMES.includes(hostname);
6
+ if (LOCAL_HOSTNAMES.includes(hostname)) {
7
+ return true;
8
+ }
9
+ const tld = hostname.split(".").pop();
10
+ if (tld && RESERVED_TLDS.includes(tld)) {
11
+ return true;
12
+ }
13
+ return false;
6
14
  } catch {
7
15
  return true;
8
16
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/url/is-local-url.ts"],
4
- "sourcesContent": ["/** Obviously local hostnames */\nconst LOCAL_HOSTNAMES = ['localhost', '127.0.0.1', '[::1]', '0.0.0.0']\n\n/**\n * Detect requests to localhost\n */\nexport function isLocalUrl(url: string) {\n try {\n const { hostname } = new URL(url)\n\n return LOCAL_HOSTNAMES.includes(hostname)\n } catch {\n // If it's not a valid URL, we can't use the proxy anyway,\n // but it also covers cases like relative URLs (e.g. `openapi.json`).\n return true\n }\n}\n"],
5
- "mappings": "AACA,MAAM,kBAAkB,CAAC,aAAa,aAAa,SAAS,SAAS;AAK9D,SAAS,WAAW,KAAa;AACtC,MAAI;AACF,UAAM,EAAE,SAAS,IAAI,IAAI,IAAI,GAAG;AAEhC,WAAO,gBAAgB,SAAS,QAAQ;AAAA,EAC1C,QAAQ;AAGN,WAAO;AAAA,EACT;AACF;",
4
+ "sourcesContent": ["/** Obviously local hostnames */\nconst LOCAL_HOSTNAMES = ['localhost', '127.0.0.1', '[::1]', '0.0.0.0']\n\n/** Reserved TLDs that are guaranteed to never be assigned */\nconst RESERVED_TLDS = ['test', 'example', 'invalid', 'localhost']\n\n/**\n * Detect requests to localhost or reserved TLDs\n */\nexport function isLocalUrl(url: string) {\n try {\n const { hostname } = new URL(url)\n\n // Check if hostname is in the local hostnames list\n if (LOCAL_HOSTNAMES.includes(hostname)) {\n return true\n }\n\n // Check if hostname ends with a reserved TLD\n const tld = hostname.split('.').pop()\n if (tld && RESERVED_TLDS.includes(tld)) {\n return true\n }\n\n return false\n } catch {\n // If it's not a valid URL, we can't use the proxy anyway,\n // but it also covers cases like relative URLs (e.g. `openapi.json`).\n return true\n }\n}\n"],
5
+ "mappings": "AACA,MAAM,kBAAkB,CAAC,aAAa,aAAa,SAAS,SAAS;AAGrE,MAAM,gBAAgB,CAAC,QAAQ,WAAW,WAAW,WAAW;AAKzD,SAAS,WAAW,KAAa;AACtC,MAAI;AACF,UAAM,EAAE,SAAS,IAAI,IAAI,IAAI,GAAG;AAGhC,QAAI,gBAAgB,SAAS,QAAQ,GAAG;AACtC,aAAO;AAAA,IACT;AAGA,UAAM,MAAM,SAAS,MAAM,GAAG,EAAE,IAAI;AACpC,QAAI,OAAO,cAAc,SAAS,GAAG,GAAG;AACtC,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT,QAAQ;AAGN,WAAO;AAAA,EACT;AACF;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "helpers",
15
15
  "js"
16
16
  ],
17
- "version": "0.0.10",
17
+ "version": "0.0.11",
18
18
  "engines": {
19
19
  "node": ">=20"
20
20
  },
@@ -78,8 +78,8 @@
78
78
  ],
79
79
  "module": "dist/index.js",
80
80
  "devDependencies": {
81
- "vite": "6.1.6",
82
- "vitest": "^3.2.4",
81
+ "vite": "7.1.5",
82
+ "vitest": "3.2.4",
83
83
  "@scalar/build-tooling": "0.2.7"
84
84
  },
85
85
  "scripts": {