filestash/public/assets/helpers/sdk.js
2024-12-24 18:10:22 +11:00

17 lines
466 B
JavaScript

// feature detection if we're using Filestash as a standalone app or as an SDK
// see: ../index.js
export function isSDK() {
const importURL = new URL(import.meta.url);
return location.origin !== importURL.origin;
}
export function urlSDK(url) {
if (url.startsWith("blob:")) return url;
const importURL = new URL(import.meta.url);
if (new RegExp("^/").test(url) === false) {
url = "/" + url;
}
return importURL.origin + url;
}