Skip to content

Commit 3a49775

Browse files
committed
updates to zephr.js. Updated way that the base URL is handled.
1 parent b160bcc commit 3a49775

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

zephyrcore/zephyr.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,19 @@
55
export default class ZephyrJS extends HTMLElement {
66
static baseUrl = '';
77

8+
/**
9+
* Sets the base URL for loading templates.
10+
* If a CDN link is provided, it is used as is.
11+
* If a relative path is provided, it's treated as a local path.
12+
*/
813
static setBaseUrl(url) {
9-
ZephyrJS.baseUrl = url.endsWith('/') ? url : url + '/';
14+
if (url.startsWith('http')) {
15+
// CDN or full URL
16+
ZephyrJS.baseUrl = url.endsWith('/') ? url : url + '/';
17+
} else {
18+
// Local relative path
19+
ZephyrJS.baseUrl = new URL(url, window.location.origin).href;
20+
}
1021
}
1122

1223
/**

0 commit comments

Comments
 (0)