UNPKG

@metamask/snaps-sdk

Version:

A library containing the core functionality for building MetaMask Snaps

21 lines 744 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.uri = void 0; const superstruct_1 = require("@metamask/superstruct"); const errors_1 = require("./errors.cjs"); const uri = (opts = {}) => (0, superstruct_1.refine)((0, superstruct_1.string)(), 'uri', (value) => { try { const url = new URL(value); const UrlStruct = (0, superstruct_1.type)(opts); (0, superstruct_1.assert)(url, UrlStruct); return true; } catch (error) { if (error instanceof superstruct_1.StructError) { return (0, errors_1.getErrorMessage)(error); } return `Expected URL, got "${value.toString()}"`; } }); exports.uri = uri; //# sourceMappingURL=uri.cjs.map