caro5 / client /src /binAssets.ts
Pedro de Carvalho
Add dragon icons
0a5fd27
Raw
History Blame Contribute Delete
694 Bytes
const DEFAULT_BIN_ASSET_BASE = 'https://huggingface.co/datasets/pedroc/caro5-game-assets/resolve/main'
const rawBase = import.meta.env.VITE_BIN_ASSET_BASE || DEFAULT_BIN_ASSET_BASE
export const BIN_ASSET_BASE = rawBase.replace(/\/+$/, '')
export function binAssetUrl(path: string): string {
const normalizedPath = path.replace(/^\/+/, '')
return `${BIN_ASSET_BASE}/${normalizedPath}`
}
const IMAGE_SYMBOL_PREFIX = 'img:'
export function isImageSymbol(sym: string | undefined | null): boolean {
return typeof sym === 'string' && sym.startsWith(IMAGE_SYMBOL_PREFIX)
}
export function imageSymbolUrl(sym: string): string {
return binAssetUrl(sym.slice(IMAGE_SYMBOL_PREFIX.length))
}