@scalar/oas-utils 0.2.76 → 0.2.77

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/oas-utils
2
2
 
3
+ ## 0.2.77
4
+
5
+ ### Patch Changes
6
+
7
+ - 44a7100: fix: handle no protocol prefix
8
+
3
9
  ## 0.2.76
4
10
 
5
11
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  /** Redirects the request to a proxy server with a given URL. */
2
2
  export declare function redirectToProxy(proxy?: string, url?: string): string;
3
- /** Check if the URL is relative, aka doesn't start with http[s] */
3
+ /** Check if the URL is relative or if it's a domain without protocol */
4
4
  export declare const isRelativePath: (url: string) => boolean;
5
5
  /** Returns false for requests to localhost, relative URLs, if no proxy is defined … */
6
6
  export declare function shouldUseProxy(proxy?: string, url?: string): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"redirectToProxy.d.ts","sourceRoot":"","sources":["../../src/helpers/redirectToProxy.ts"],"names":[],"mappings":"AAEA,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAepE;AAED,mEAAmE;AACnE,eAAO,MAAM,cAAc,QAAS,MAAM,YAA8B,CAAA;AAExE,uFAAuF;AACvF,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAWpE"}
1
+ {"version":3,"file":"redirectToProxy.d.ts","sourceRoot":"","sources":["../../src/helpers/redirectToProxy.ts"],"names":[],"mappings":"AAEA,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAepE;AAED,wEAAwE;AACxE,eAAO,MAAM,cAAc,QAAS,MAAM,YAazC,CAAA;AAED,uFAAuF;AACvF,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAWpE"}
@@ -13,8 +13,19 @@ function redirectToProxy(proxy, url) {
13
13
  newUrl.searchParams.append('scalar_url', url);
14
14
  return newUrl.toString();
15
15
  }
16
- /** Check if the URL is relative, aka doesn't start with http[s] */
17
- const isRelativePath = (url) => !/^https?:\/\//.test(url);
16
+ /** Check if the URL is relative or if it's a domain without protocol */
17
+ const isRelativePath = (url) => {
18
+ // Absolute URLs start with http:// or https://
19
+ if (url.startsWith('http://') || url.startsWith('https://')) {
20
+ return false;
21
+ }
22
+ // Check if it looks like a domain (contains dots and no spaces)
23
+ // This catches cases like "galaxy.scalar.com/planets"
24
+ if (/^[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+(\/|$)/.test(url)) {
25
+ return false;
26
+ }
27
+ return true;
28
+ };
18
29
  /** Returns false for requests to localhost, relative URLs, if no proxy is defined … */
19
30
  function shouldUseProxy(proxy, url) {
20
31
  // No proxy or url
@@ -1,5 +1,6 @@
1
1
  export declare const REGEX: {
2
2
  readonly VARIABLES: RegExp;
3
3
  readonly PATH: RegExp;
4
+ readonly TEMPLATE_VARIABLE: RegExp;
4
5
  };
5
6
  //# sourceMappingURL=regexHelpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"regexHelpers.d.ts","sourceRoot":"","sources":["../../src/helpers/regexHelpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK;;;CAGR,CAAA"}
1
+ {"version":3,"file":"regexHelpers.d.ts","sourceRoot":"","sources":["../../src/helpers/regexHelpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK;;;;CAIR,CAAA"}
@@ -1,6 +1,7 @@
1
1
  const REGEX = {
2
2
  VARIABLES: /{{((?:[^{}]|{[^{}]*})*)}}/g,
3
3
  PATH: /(?:{)([^{}]+)}(?!})/g,
4
+ TEMPLATE_VARIABLE: /{{\s*([^}\s]+?)\s*}}|{\s*([^}\s]+?)\s*}|:\b[\w.]+\b/g,
4
5
  };
5
6
 
6
7
  export { REGEX };
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "specification",
17
17
  "yaml"
18
18
  ],
19
- "version": "0.2.76",
19
+ "version": "0.2.77",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -107,18 +107,18 @@
107
107
  "yaml": "^2.4.5",
108
108
  "zod": "^3.23.8",
109
109
  "@scalar/openapi-types": "0.1.5",
110
- "@scalar/themes": "0.9.48",
111
110
  "@scalar/object-utils": "1.1.12",
111
+ "@scalar/themes": "0.9.48",
112
112
  "@scalar/types": "0.0.19"
113
113
  },
114
114
  "devDependencies": {
115
115
  "type-fest": "^4.20.0",
116
- "vite": "^5.4.9",
116
+ "vite": "^5.4.10",
117
117
  "vitest": "^1.6.0",
118
118
  "zod-to-ts": "^1.2.0",
119
119
  "@scalar/build-tooling": "0.1.12",
120
- "@scalar/openapi-types": "0.1.5",
121
- "@scalar/openapi-parser": "0.8.9"
120
+ "@scalar/openapi-parser": "0.8.10",
121
+ "@scalar/openapi-types": "0.1.5"
122
122
  },
123
123
  "scripts": {
124
124
  "build": "scalar-build-rollup",