Skip to content

Commit

Permalink
updates to zephr.js. Updated way that the base URL is handled.
Browse files Browse the repository at this point in the history
  • Loading branch information
RPDevJesco committed Aug 18, 2024
1 parent b160bcc commit 3a49775
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion zephyrcore/zephyr.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,19 @@
export default class ZephyrJS extends HTMLElement {
static baseUrl = '';

/**
* Sets the base URL for loading templates.
* If a CDN link is provided, it is used as is.
* If a relative path is provided, it's treated as a local path.
*/
static setBaseUrl(url) {
ZephyrJS.baseUrl = url.endsWith('/') ? url : url + '/';
if (url.startsWith('http')) {
// CDN or full URL
ZephyrJS.baseUrl = url.endsWith('/') ? url : url + '/';
} else {
// Local relative path
ZephyrJS.baseUrl = new URL(url, window.location.origin).href;
}
}

/**
Expand Down

0 comments on commit 3a49775

Please sign in to comment.