add entity type prefix to buildWikiJaUrl for weapons/summons
This commit is contained in:
parent
321e7585b8
commit
552c73823d
1 changed files with 17 additions and 3 deletions
|
|
@ -30,15 +30,29 @@ export function buildWikiEnUrl(pageName: string | undefined | null): string | nu
|
||||||
return `${WIKI_EN_BASE}/${encoded}`
|
return `${WIKI_EN_BASE}/${encoded}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Japanese wiki paths by entity type
|
||||||
|
const WIKI_JA_PATHS = {
|
||||||
|
character: '', // no prefix
|
||||||
|
weapon: '武器/',
|
||||||
|
summon: '召喚石/'
|
||||||
|
} as const
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build Japanese wiki URL from page name
|
* Build Japanese wiki URL from page name
|
||||||
* Input: "フロレンス (SSR)闇属性バージョン"
|
* Input: "フロレンス (SSR)闇属性バージョン", entityType: "character"
|
||||||
* Output: "https://gbf-wiki.com/?フロレンス+(SSR)闇属性バージョン"
|
* Output: "https://gbf-wiki.com/?フロレンス+(SSR)闇属性バージョン"
|
||||||
|
*
|
||||||
|
* Input: "新神気鋭・猫之印 (SSR)", entityType: "weapon"
|
||||||
|
* Output: "https://gbf-wiki.com/?武器/新神気鋭・猫之印+(SSR)"
|
||||||
*/
|
*/
|
||||||
export function buildWikiJaUrl(pageName: string | undefined | null): string | null {
|
export function buildWikiJaUrl(
|
||||||
|
pageName: string | undefined | null,
|
||||||
|
entityType?: EntityType
|
||||||
|
): string | null {
|
||||||
if (!pageName?.trim()) return null
|
if (!pageName?.trim()) return null
|
||||||
|
const prefix = entityType ? WIKI_JA_PATHS[entityType] : ''
|
||||||
// Japanese wiki uses query string with + for spaces
|
// Japanese wiki uses query string with + for spaces
|
||||||
const encoded = encodeURIComponent(pageName.trim()).replace(/%20/g, '+')
|
const encoded = encodeURIComponent(prefix + pageName.trim()).replace(/%20/g, '+')
|
||||||
return `${WIKI_JA_BASE}/?${encoded}`
|
return `${WIKI_JA_BASE}/?${encoded}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue