(location: Partial<IconsAssetsLocation>, path: string)
| 53 | * Get the URL for an asset. |
| 54 | */ |
| 55 | export function getAssetURL(location: Partial<IconsAssetsLocation>, path: string): string { |
| 56 | if (!location.assetsURL) { |
| 57 | throw new Error('You first need to pass a assetsURL to <IconsProvider>'); |
| 58 | } |
| 59 | const rawUrl = `${location.assetsURL + (location.assetsURL.endsWith('/') ? '' : '/') + path}?v=${version}`; |
| 60 | |
| 61 | if (location.assetsURLToken) { |
| 62 | const url = new URL(rawUrl); |
| 63 | url.searchParams.set('token', location.assetsURLToken); |
| 64 | return url.toString(); |
| 65 | } |
| 66 | return rawUrl; |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Get the URL for the SVG of an icon. |
no test coverage detected