fix: issue with asset names case-insensitive (#760)

# PR Checklist
- [ ] Have you checked if it works normally in all models? *Ignore this
if it doesn't use models.*
- [ ] Have you checked if it works normally in all web, local, and node
hosted versions? If it doesn't, have you blocked it in those versions?
- [ ] Have you added type definitions?

# Description
This PR addresses the issue where asset names were only recognized when
entered in lowercase, even if they were originally uppercase. It ensures
that asset names are now case-insensitive, aligning with the intended
behavior.
This commit is contained in:
kwaroran
2025-02-16 19:15:07 +09:00
committed by GitHub
2 changed files with 5 additions and 2 deletions

View File

@@ -303,7 +303,6 @@ async function replaceAsync(string, regexp, replacerFunction) {
}
async function getAssetSrc(assetArr: string[][], name: string, assetPaths: {[key: string]:{path: string, ext?: string}}) {
name = name.toLocaleLowerCase()
for (const asset of assetArr) {
if (trimmer(asset[0].toLocaleLowerCase()) !== trimmer(name)) continue
const assetPath = await getFileSrc(asset[1])
@@ -341,6 +340,7 @@ async function parseAdditionalAssets(data:string, char:simpleCharacterArgument|c
let needsSourceAccess = false
data = await replaceAsync(data, assetRegex, async (full:string, type:string, name:string) => {
name = name.toLocaleLowerCase()
const moduleAssets = getModuleAssets()
if (char.additionalAssets) {
await getAssetSrc(char.additionalAssets, name, assetPaths)

View File

@@ -268,7 +268,10 @@ function getModuleByIds(ids:string[]){
modules.push(module)
}
}
return deduplicateModuleById(modules)
if(db.moduleIntergration){
modules = deduplicateModuleById(modules)
}
return modules
}
function deduplicateModuleById(modules:RisuModule[]){