MCPcopy
hub / github.com/ionic-team/ionicons / getSvgContent

Function getSvgContent

src/components/icon/request.ts:17–39  ·  view source on GitHub ↗
(url: string, sanitize: boolean)

Source from the content-addressed store, hash-verified

15}
16
17export const getSvgContent = (url: string, sanitize: boolean): Promise<string> => {
18 /**
19 * See if we already have a request for this url
20 */
21 const req = requests.get(url);
22 if (req) {
23 return req;
24 }
25
26 if (typeof fetch !== 'undefined' && typeof document !== 'undefined') {
27 /**
28 * If the url is a data url of an svg, then try to parse it
29 * with the DOMParser. This works with content security policies enabled.
30 */
31 if (isSvgDataUrl(url) && isEncodedDataUrl(url)) {
32 return Promise.resolve(getSvgByUrl(url));
33 }
34
35 return fetchSvg(url, sanitize);
36 }
37
38 return Promise.resolve(safeFallback(url));
39};
40
41function getSvgByUrl(url: string): string {
42 if (!parser) {

Callers 1

loadIconMethod · 0.90

Calls 5

isSvgDataUrlFunction · 0.90
isEncodedDataUrlFunction · 0.90
getSvgByUrlFunction · 0.85
fetchSvgFunction · 0.85
safeFallbackFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…