UNPKG

request-mocking-protocol

Version:
22 lines 823 B
"use strict"; /** * Schema to match the request. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.buildMockRequestSchema = buildMockRequestSchema; exports.toMockRequestSchemaObject = toMockRequestSchemaObject; function buildMockRequestSchema(init) { const initObj = toMockRequestSchemaObject(init); const { url, ...rest } = initObj; if (url instanceof RegExp) rest.patternType = 'regexp'; // always convert url to string to handle regexp const urlStr = url.toString(); return Object.assign({ url: urlStr }, rest); } function toMockRequestSchemaObject(init) { if (!init) throw new Error('Request schema cannot be empty.'); return typeof init === 'string' || init instanceof RegExp ? { url: init } : init; } //# sourceMappingURL=request-schema.js.map