@scalar/oas-utils
Advanced tools
Comparing version 0.2.81 to 0.2.82
# @scalar/oas-utils | ||
## 0.2.82 | ||
### Patch Changes | ||
- 6389557: feat: allow to pass a base URL to makeUrlAbsolute | ||
- Updated dependencies [baaad1c] | ||
- Updated dependencies [c984ac8] | ||
- @scalar/types@0.0.22 | ||
- @scalar/themes@0.9.53 | ||
## 0.2.81 | ||
@@ -4,0 +14,0 @@ |
/** | ||
* Pass an URL or a relative URL and get an absolute URL | ||
*/ | ||
export declare const makeUrlAbsolute: (url?: string) => string | undefined; | ||
export declare const makeUrlAbsolute: (url?: string, baseUrl?: string) => string | undefined; | ||
//# sourceMappingURL=makeUrlAbsolute.d.ts.map |
/** | ||
* Pass an URL or a relative URL and get an absolute URL | ||
*/ | ||
const makeUrlAbsolute = (url) => { | ||
const makeUrlAbsolute = (url, baseUrl) => { | ||
if (!url || | ||
url.startsWith('http://') || | ||
url.startsWith('https://') || | ||
typeof window === 'undefined') | ||
(typeof window === 'undefined' && !baseUrl)) { | ||
return url; | ||
const baseUrl = window.location.href; | ||
} | ||
const base = baseUrl || window.location.href; | ||
// Remove any query parameters or hash from the base URL | ||
const cleanBaseUrl = baseUrl.split('?')[0]?.split('#')[0]; | ||
const cleanBaseUrl = base.split('?')[0]?.split('#')[0]; | ||
// For base URLs with a path component, we want to remove the last path segment | ||
@@ -14,0 +15,0 @@ // if it doesn't end with a slash |
@@ -19,3 +19,3 @@ { | ||
], | ||
"version": "0.2.81", | ||
"version": "0.2.82", | ||
"engines": { | ||
@@ -117,4 +117,4 @@ "node": ">=18" | ||
"@scalar/openapi-types": "0.1.5", | ||
"@scalar/themes": "0.9.52", | ||
"@scalar/types": "0.0.21" | ||
"@scalar/themes": "0.9.53", | ||
"@scalar/types": "0.0.22" | ||
}, | ||
@@ -127,4 +127,4 @@ "devDependencies": { | ||
"@scalar/build-tooling": "0.1.12", | ||
"@scalar/openapi-parser": "0.8.10", | ||
"@scalar/openapi-types": "0.1.5" | ||
"@scalar/openapi-types": "0.1.5", | ||
"@scalar/openapi-parser": "0.8.10" | ||
}, | ||
@@ -131,0 +131,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
453593
9238
+ Added@scalar/themes@0.9.53(transitive)
+ Added@scalar/types@0.0.22(transitive)
- Removed@scalar/themes@0.9.52(transitive)
- Removed@scalar/types@0.0.21(transitive)
Updated@scalar/themes@0.9.53
Updated@scalar/types@0.0.22