Skip to content

Commit 4a7f6f5

Browse files
committed
fixed jsdelivr and github urls failing in 404
1 parent 1cb81cc commit 4a7f6f5

3 files changed

Lines changed: 26 additions & 24 deletions

File tree

assets/changes.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ <h2>V4.1 -- What's New:</h2>
88
<!-- May 18, 2025 -->
99
<article class="changelog-entry">
1010
<h3 class="changelog-version">Commits on May 18, 2025</h3>
11-
<p class="changelog-date">May 16, 2025</p>
11+
<p class="changelog-date">May 18, 2025</p>
1212
<ul>
13-
<li><strong>[NONEYET] Fck ton of refactoring: 4.0 -> 4.1</strong><br>
13+
<li><strong>[HOTFIX]</strong> fixed jsdelivr and github urls failing in 404</li>
14+
<li><strong>[1cb81cc] Fck ton of refactoring: 4.0 -> 4.1</strong><br>
1415
refactor: script.js, repoexplorer.js, styles.css, repoexplorer.css
1516
<br>
1617
small modifications: icon.svg, changes.html, ztodo.txt, index.html, extra.js

js/repoexplorer.js

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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 = /(.*)(model3?|model)\.json$/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') {

ztodo.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Priority:
88
- Improve import model button in explorer
99
- Cutom look for title="" like tool tip
1010
- Smoother animations
11-
- Jsdelivr url fetching behaves weird
11+
- Search in repoexplorer when beginning to type
1212

1313
Other:
1414
- Refactor all files 1st, 2nd, 3rd(css), 4th, 5th, 6th,

0 commit comments

Comments
 (0)