MCPcopy
hub / github.com/GitbookIO/gitbook / getAssetURL

Function getAssetURL

packages/icons/src/IconsProvider.tsx:55–67  ·  view source on GitHub ↗
(location: Partial<IconsAssetsLocation>, path: string)

Source from the content-addressed store, hash-verified

53 * Get the URL for an asset.
54 */
55export 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.

Callers 1

getIconAssetURLFunction · 0.70

Calls 2

setMethod · 0.80
toStringMethod · 0.80

Tested by

no test coverage detected