From 6e6662553c0eaab789c2440918238731b5bc8b57 Mon Sep 17 00:00:00 2001 From: Rintim Date: Sun, 21 Apr 2024 21:24:24 +0800 Subject: [PATCH] fix: audio path fix. --- noname/game/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/noname/game/index.js b/noname/game/index.js index 9887c3a8b..0b681754f 100644 --- a/noname/game/index.js +++ b/noname/game/index.js @@ -1469,6 +1469,7 @@ export class Game { reject ); else if (lib.path.extname(path)) resolve(`${lib.assetURL}${path}`); + else if (URL.canParse(path)) resolve(path); else resolve(`${lib.assetURL}${path}.mp3`); }).then((resolvedPath) => { audio.src = resolvedPath; @@ -1603,7 +1604,11 @@ export class Game { let path = "", format = ""; if (!/^db:|^ext:|\//.test(audioInfo)) path = "skill/"; - if (!/\.\w+$/.test(audioInfo)) format = ".mp3"; + if ( + !/\.\w+$/.test(audioInfo) && + !["data:", "blob:"].some((name) => audioInfo.startsWith(name)) + ) + format = ".mp3"; if (path && format) return parseAudio(audioInfo, options, [true, 2]); return [`${path}${audioInfo}${format}`]; }