Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
15 lines
602 B
Plaintext
15 lines
602 B
Plaintext
const getAbsoluteUrl = url => {
|
|
try {
|
|
return new URL(url, window.location.origin).href;
|
|
} catch {
|
|
return url;
|
|
}
|
|
};
|
|
/**
|
|
* Ensures the provided URL is absolute. If not, it converts it to an absolute URL based
|
|
* on the current window location.
|
|
* Note: This MUST be called within the client environment as it relies on the `window` object
|
|
* to determine the absolute URL.
|
|
*/
|
|
export const formatAbsoluteURL = incomingURL => incomingURL?.startsWith('http://') || incomingURL?.startsWith('https://') ? incomingURL : getAbsoluteUrl(incomingURL);
|
|
//# sourceMappingURL=formatAbsoluteURL.js.map |