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:
@@ -303,7 +303,6 @@ async function replaceAsync(string, regexp, replacerFunction) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getAssetSrc(assetArr: string[][], name: string, assetPaths: {[key: string]:{path: string, ext?: string}}) {
|
async function getAssetSrc(assetArr: string[][], name: string, assetPaths: {[key: string]:{path: string, ext?: string}}) {
|
||||||
name = name.toLocaleLowerCase()
|
|
||||||
for (const asset of assetArr) {
|
for (const asset of assetArr) {
|
||||||
if (trimmer(asset[0].toLocaleLowerCase()) !== trimmer(name)) continue
|
if (trimmer(asset[0].toLocaleLowerCase()) !== trimmer(name)) continue
|
||||||
const assetPath = await getFileSrc(asset[1])
|
const assetPath = await getFileSrc(asset[1])
|
||||||
@@ -341,6 +340,7 @@ async function parseAdditionalAssets(data:string, char:simpleCharacterArgument|c
|
|||||||
let needsSourceAccess = false
|
let needsSourceAccess = false
|
||||||
|
|
||||||
data = await replaceAsync(data, assetRegex, async (full:string, type:string, name:string) => {
|
data = await replaceAsync(data, assetRegex, async (full:string, type:string, name:string) => {
|
||||||
|
name = name.toLocaleLowerCase()
|
||||||
const moduleAssets = getModuleAssets()
|
const moduleAssets = getModuleAssets()
|
||||||
if (char.additionalAssets) {
|
if (char.additionalAssets) {
|
||||||
await getAssetSrc(char.additionalAssets, name, assetPaths)
|
await getAssetSrc(char.additionalAssets, name, assetPaths)
|
||||||
|
|||||||
@@ -268,7 +268,10 @@ function getModuleByIds(ids:string[]){
|
|||||||
modules.push(module)
|
modules.push(module)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return deduplicateModuleById(modules)
|
if(db.moduleIntergration){
|
||||||
|
modules = deduplicateModuleById(modules)
|
||||||
|
}
|
||||||
|
return modules
|
||||||
}
|
}
|
||||||
|
|
||||||
function deduplicateModuleById(modules:RisuModule[]){
|
function deduplicateModuleById(modules:RisuModule[]){
|
||||||
|
|||||||
Reference in New Issue
Block a user