import type { ILoaderResource } from '@pixi/loaders' ; import { supported } from './supported' ; ignore const FORMAT_PATTERN = /\.(\{([^\}]+)\})(\?.*)?$/ ; memberof param { string | PIXI . LoaderResource } source return function resolveUrl ( source ) { const glob = FORMAT_PATTERN ; const url = typeof source === 'string' ? source : source . url ; if ( ! glob . test ( url ) ) { return url ; } const match = glob . exec ( url ) ; const exts = match [ 2 ] . split ( ',' ) ; let replace = exts [ exts . length - 1 ] ; for ( let i = 0 , len = exts . length ; i < len ; i ++ ) { const ext = exts [ i ] ; if ( supported [ ext ] ) { replace = ext ; break ; } } const resolved = url . replace ( match [ 1 ] , replace ) ; if ( ! ( typeof source === 'string' ) ) { const writableSource = source as { extension : string ; url : string ; } ; writableSource . extension = replace ; writableSource . url = resolved ; } return resolved ; } export { resolveUrl } ;