mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-06 08:22:24 +01:00
18 lines
548 B
JavaScript
18 lines
548 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;
|
|
else if (url.startsWith("http://") || url.startsWith("https://")) return url;
|
|
|
|
const importURL = new URL(import.meta.url);
|
|
if (new RegExp("^/").test(url) === false) {
|
|
url = "/" + url;
|
|
}
|
|
return importURL.origin + url;
|
|
}
|