Skip to content

Commit 50ce046

Browse files
committed
Fix demo to use CDN URL when deployed to GitHub Pages
Use local dist path for development, CDN (unpkg) for deployed demo.
1 parent a0a110d commit 50ce046

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

demo/index.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,20 @@ <h1>service-injector Demo</h1>
322322
injectorStyleElement = null;
323323
}
324324

325+
// Determine script URL based on environment (local vs deployed)
326+
function getScriptUrl() {
327+
var isLocal = window.location.hostname === 'localhost' ||
328+
window.location.hostname === '127.0.0.1' ||
329+
window.location.protocol === 'file:';
330+
331+
if (isLocal) {
332+
return '../dist/index.iife.js';
333+
} else {
334+
// Use CDN for deployed demo
335+
return 'https://unpkg.com/service-injector/dist/index.iife.js';
336+
}
337+
}
338+
325339
// Load injector with current configuration
326340
function loadInjector() {
327341
// Clean up any existing injector
@@ -352,7 +366,7 @@ <h1>service-injector Demo</h1>
352366
// Create and inject new script
353367
var script = document.createElement('script');
354368
script.id = 'service-injector';
355-
script.src = '../dist/index.iife.js' + queryString;
369+
script.src = getScriptUrl() + queryString;
356370

357371
// Track the style element that will be added
358372
var styleCount = document.querySelectorAll('style').length;

0 commit comments

Comments
 (0)