@@ -38,26 +38,27 @@ document.addEventListener('DOMContentLoaded', () => {
3838
3939 const GITHUB_API_BASE = 'https://api.github.com/repos' ;
4040 const JSDELIVR_CDN_BASE = 'https://cdn.jsdelivr.net/gh' ;
41+ const DEFAULT_BRANCHE = '@master' ;
4142 const MODEL_FILE_REGEX = / ( .* ) ( m o d e l 3 ? | m o d e l ) \. j s o n $ / i; // Precise regex for model files
42- // ✅ Matches (allowed)
43- // Ends exactly in "model.json"
44- "model.json" ; // ✅ no prefix, ends with model.json
45- "model3.json" ; // ✅ no prefix, ends with model3.json
46- "bronya.model.json" ; // ✅ has prefix, ends with model.json
47- "kiana-model3.json" ; // ✅ has prefix, ends with model3.json
48- "abc.model3.json" ; // ✅ valid prefix, ends with model3.json
49- "json.model.json" ; // ✅ valid prefix, ends with model.json
50- "dir/abc.model3.json" ; // ✅ full path, filename ends with model3.json
51-
52- // ❌ Non-matches (rejected)
53- // Invalid due to extra chars between 'model' and '.json' or bad ending
54- "modelx.json" ; // ❌ "modelx" is not allowed — must be exactly "model"
55- "model3a.json" ; // ❌ extra 'a' after "model3" — only "model" or "model3" allowed
56- "model.json.bak" ; // ❌ ends with ".bak", not ".json"
57- "modeljson" ; // ❌ missing dot before "json"
58- "some.model2.json" ; // ❌ "model2" is not allowed — only "model" or "model3"
59- "model.3.json" ; // ❌ invalid pattern — "model.3" is not "model3"
60- "file.model3.json.backup" ; // ❌ ends with ".backup", not ".json"
43+ // ✅ Matches (allowed)
44+ // Ends exactly in "model.json"
45+ "model.json" ; // ✅ no prefix, ends with model.json
46+ "model3.json" ; // ✅ no prefix, ends with model3.json
47+ "bronya.model.json" ; // ✅ has prefix, ends with model.json
48+ "kiana-model3.json" ; // ✅ has prefix, ends with model3.json
49+ "abc.model3.json" ; // ✅ valid prefix, ends with model3.json
50+ "json.model.json" ; // ✅ valid prefix, ends with model.json
51+ "dir/abc.model3.json" ; // ✅ full path, filename ends with model3.json
52+
53+ // ❌ Non-matches (rejected)
54+ // Invalid due to extra chars between 'model' and '.json' or bad ending
55+ "modelx.json" ; // ❌ "modelx" is not allowed — must be exactly "model"
56+ "model3a.json" ; // ❌ extra 'a' after "model3" — only "model" or "model3" allowed
57+ "model.json.bak" ; // ❌ ends with ".bak", not ".json"
58+ "modeljson" ; // ❌ missing dot before "json"
59+ "some.model2.json" ; // ❌ "model2" is not allowed — only "model" or "model3"
60+ "model.3.json" ; // ❌ invalid pattern — "model.3" is not "model3"
61+ "file.model3.json.backup" ; // ❌ ends with ".backup", not ".json"
6162
6263 //==============================================================================
6364 // MODAL VISIBILITY & CONTROL
@@ -370,7 +371,7 @@ document.addEventListener('DOMContentLoaded', () => {
370371 filePreviewContainer . style . display = 'flex' ;
371372 showLoaderFE ( true ) ;
372373
373- const jsDelivrUrl = `${ JSDELIVR_CDN_BASE } /${ currentOwner } /${ currentRepo } /${ fileItem . path } / ` ;
374+ const jsDelivrUrl = `${ JSDELIVR_CDN_BASE } /${ currentOwner } /${ currentRepo } ${ DEFAULT_BRANCHE } /${ fileItem . path } ` ;
374375 const rawGitHubUrl = fileItem . open_url ; // open_url is usually the raw content URL
375376
376377 try {
@@ -548,7 +549,7 @@ document.addEventListener('DOMContentLoaded', () => {
548549 function handleImportModel ( fileItem , sourceUrlOverride = null ) {
549550 // Prefer open_url if available and no override, as it's the direct raw content link.
550551 // Fallback to jsDelivr if open_url is not present (should be rare for files).
551- const modelUrl = sourceUrlOverride || fileItem . open_url || `${ JSDELIVR_CDN_BASE } /${ currentOwner } /${ currentRepo } /${ fileItem . path } ` ;
552+ const modelUrl = sourceUrlOverride || fileItem . open_url || `${ JSDELIVR_CDN_BASE } /${ currentOwner } /${ currentRepo } ${ DEFAULT_BRANCHE } /${ fileItem . path } ` ;
552553 console . log ( `Attempting to import Live2D Model: ${ modelUrl } ` ) ;
553554
554555 if ( window . loadLive2DModel && typeof window . loadLive2DModel === 'function' ) {
0 commit comments