@scalar/helpers 0.0.9 → 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 +12 -0
- package/dist/general/has-modifier.d.ts +7 -0
- package/dist/general/has-modifier.d.ts.map +1 -0
- package/dist/general/has-modifier.js +9 -0
- package/dist/general/has-modifier.js.map +7 -0
- package/dist/regex/regex-helpers.d.ts +2 -0
- package/dist/regex/regex-helpers.d.ts.map +1 -1
- package/dist/regex/regex-helpers.js +2 -0
- package/dist/regex/regex-helpers.js.map +2 -2
- package/dist/url/is-local-url.d.ts +1 -1
- package/dist/url/is-local-url.d.ts.map +1 -1
- package/dist/url/is-local-url.js +9 -1
- package/dist/url/is-local-url.js.map +2 -2
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-modifier.d.ts","sourceRoot":"","sources":["../../src/general/has-modifier.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,aAAa,YAGjD,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/general/has-modifier.ts"],
|
|
4
|
+
"sourcesContent": ["import { isMacOS } from './is-mac-os'\n\n/**\n * Checks for the modifier key\n *\n * Which is meta on macOs and ctrl on linux/windows\n */\nexport const hasModifier = (keydown: KeyboardEvent) => {\n const modifier = isMacOS() ? 'metaKey' : 'ctrlKey'\n return keydown[modifier]\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,eAAe;AAOjB,MAAM,cAAc,CAAC,YAA2B;AACrD,QAAM,WAAW,QAAQ,IAAI,YAAY;AACzC,SAAO,QAAQ,QAAQ;AACzB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -5,6 +5,8 @@ export declare const REGEX: {
|
|
|
5
5
|
readonly MULTIPLE_SLASHES: RegExp;
|
|
6
6
|
readonly VARIABLES: RegExp;
|
|
7
7
|
readonly PATH: RegExp;
|
|
8
|
+
/** Finds the name of the schema from the ref path */
|
|
9
|
+
readonly REF_NAME: RegExp;
|
|
8
10
|
readonly TEMPLATE_VARIABLE: RegExp;
|
|
9
11
|
};
|
|
10
12
|
//# sourceMappingURL=regex-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regex-helpers.d.ts","sourceRoot":"","sources":["../../src/regex/regex-helpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK;IAChB,gCAAgC;;IAEhC,6EAA6E
|
|
1
|
+
{"version":3,"file":"regex-helpers.d.ts","sourceRoot":"","sources":["../../src/regex/regex-helpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK;IAChB,gCAAgC;;IAEhC,6EAA6E;;;;IAI7E,qDAAqD;;;CAG7C,CAAA"}
|
|
@@ -5,6 +5,8 @@ const REGEX = {
|
|
|
5
5
|
MULTIPLE_SLASHES: /(?<!:)\/{2,}/g,
|
|
6
6
|
VARIABLES: /{{((?:[^{}]|{[^{}]*})*)}}/g,
|
|
7
7
|
PATH: /(?:{)([^{}]+)}(?!})/g,
|
|
8
|
+
/** Finds the name of the schema from the ref path */
|
|
9
|
+
REF_NAME: /\/([^\/]+)$/,
|
|
8
10
|
TEMPLATE_VARIABLE: /{{\s*([^}\s]+?)\s*}}|{\s*([^}\s]+?)\s*}|:\b[\w.]+\b/g
|
|
9
11
|
};
|
|
10
12
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/regex/regex-helpers.ts"],
|
|
4
|
-
"sourcesContent": ["export const REGEX = {\n /** Checks for a valid scheme */\n PROTOCOL: /^(?:https?|ftp|file|mailto|tel|data|wss?)*:\\/\\//,\n /** Finds multiple slashes after the scheme to replace with a single slash */\n MULTIPLE_SLASHES: /(?<!:)\\/{2,}/g,\n VARIABLES: /{{((?:[^{}]|{[^{}]*})*)}}/g,\n PATH: /(?:{)([^{}]+)}(?!})/g,\n TEMPLATE_VARIABLE: /{{\\s*([^}\\s]+?)\\s*}}|{\\s*([^}\\s]+?)\\s*}|:\\b[\\w.]+\\b/g,\n} as const\n"],
|
|
5
|
-
"mappings": "AAAO,MAAM,QAAQ;AAAA;AAAA,EAEnB,UAAU;AAAA;AAAA,EAEV,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,MAAM;AAAA,
|
|
4
|
+
"sourcesContent": ["export const REGEX = {\n /** Checks for a valid scheme */\n PROTOCOL: /^(?:https?|ftp|file|mailto|tel|data|wss?)*:\\/\\//,\n /** Finds multiple slashes after the scheme to replace with a single slash */\n MULTIPLE_SLASHES: /(?<!:)\\/{2,}/g,\n VARIABLES: /{{((?:[^{}]|{[^{}]*})*)}}/g,\n PATH: /(?:{)([^{}]+)}(?!})/g,\n /** Finds the name of the schema from the ref path */\n REF_NAME: /\\/([^\\/]+)$/,\n TEMPLATE_VARIABLE: /{{\\s*([^}\\s]+?)\\s*}}|{\\s*([^}\\s]+?)\\s*}|:\\b[\\w.]+\\b/g,\n} as const\n"],
|
|
5
|
+
"mappings": "AAAO,MAAM,QAAQ;AAAA;AAAA,EAEnB,UAAU;AAAA;AAAA,EAEV,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,MAAM;AAAA;AAAA,EAEN,UAAU;AAAA,EACV,mBAAmB;AACrB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-local-url.d.ts","sourceRoot":"","sources":["../../src/url/is-local-url.ts"],"names":[],"mappings":"
|
|
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"}
|
package/dist/url/is-local-url.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
5
|
-
"mappings": "AACA,MAAM,kBAAkB,CAAC,aAAa,aAAa,SAAS,SAAS;
|
|
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.
|
|
17
|
+
"version": "0.0.11",
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=20"
|
|
20
20
|
},
|
|
@@ -78,9 +78,9 @@
|
|
|
78
78
|
],
|
|
79
79
|
"module": "dist/index.js",
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"vite": "
|
|
82
|
-
"vitest": "
|
|
83
|
-
"@scalar/build-tooling": "0.2.
|
|
81
|
+
"vite": "7.1.5",
|
|
82
|
+
"vitest": "3.2.4",
|
|
83
|
+
"@scalar/build-tooling": "0.2.7"
|
|
84
84
|
},
|
|
85
85
|
"scripts": {
|
|
86
86
|
"build": "scalar-build-esbuild",
|