We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b160bcc commit 3a49775Copy full SHA for 3a49775
zephyrcore/zephyr.js
@@ -5,8 +5,19 @@
5
export default class ZephyrJS extends HTMLElement {
6
static baseUrl = '';
7
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
+ */
13
static setBaseUrl(url) {
- 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
+ }
21
}
22
23
/**
0 commit comments