UNPKG

mockttp

Version:

Mock HTTP server for testing HTTP clients and stubbing webservices

19 lines (16 loc) 506 B
export function shouldPassThrough( hostname: string | undefined, // Only one of these two should have values (validated above): passThroughPatterns: URLPattern[], interceptOnlyPatterns: URLPattern[] | undefined ): hostname is string { if (!hostname) return false; if (interceptOnlyPatterns) { return !interceptOnlyPatterns.some((pattern) => pattern.test(`https://${hostname}`) ); } return passThroughPatterns.some((pattern) => pattern.test(`https://${hostname}`) ); }