@metamask/snaps-sdk
Version:
A library containing the core functionality for building MetaMask Snaps
1 lines • 1.03 kB
Source Map (JSON)
{"version":3,"file":"svg.cjs","sourceRoot":"","sources":["../../src/internals/svg.ts"],"names":[],"mappings":";;;AAAA,uDAAuD;AAEvD;;;;;GAKG;AACH,SAAgB,GAAG;IACjB,OAAO,IAAA,oBAAM,EAAC,IAAA,oBAAM,GAAE,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;QACvC,+EAA+E;QAC/E,0EAA0E;QAC1E,mBAAmB;QACnB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,OAAO,2BAA2B,CAAC;QACrC,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAXD,kBAWC","sourcesContent":["import { refine, string } from '@metamask/superstruct';\n\n/**\n * Get a Struct that validates a string as a valid SVG.\n *\n * @returns A Struct that validates a string as a valid SVG.\n * @internal\n */\nexport function svg() {\n return refine(string(), 'SVG', (value) => {\n // This validation is intentionally very basic, we don't need to be that strict\n // and merely have this extra validation as a helpful error if devs aren't\n // passing in SVGs.\n if (!value.includes('<svg')) {\n return 'Value is not a valid SVG.';\n }\n\n return true;\n });\n}\n"]}