{"version":3,"file":"is-remote-pattern-match.cjs","sources":["../../src/images/is-remote-pattern-match.ts"],"sourcesContent":["import type { RemotePattern } from './types';\n\n/**\n * Checks whether the given URL matches the given remote pattern from the build output images\n * configuration.\n *\n * https://vercel.com/docs/build-output-api/v3/configuration#images\n *\n * @param url URL to check.\n * @param pattern Remote pattern to match against.\n * @returns Whether the URL matches the remote pattern.\n */\nexport const isRemotePatternMatch = (\n\turl: URL,\n\t{ protocol, hostname, port, pathname }: RemotePattern,\n): boolean => {\n\t// Protocol must match if defined.\n\tif (protocol && url.protocol.replace(/:$/, '') !== protocol) return false;\n\t// Hostname must match regexp.\n\tif (!new RegExp(hostname).test(url.hostname)) return false;\n\t// Port must match regexp if defined.\n\tif (port && !new RegExp(port).test(url.port)) return false;\n\t// Pathname must match regexp if defined.\n\tif (pathname && !new RegExp(pathname).test(url.pathname)) return false;\n\t// All checks passed.\n\treturn true;\n};\n"],"names":["isRemotePatternMatch","url","protocol","hostname","port","pathname"],"mappings":"gFAYa,MAAAA,EAAuB,CACnCC,EACA,CAAE,SAAAC,EAAU,SAAAC,EAAU,KAAAC,EAAM,SAAAC,KAGxB,EAAAH,GAAYD,EAAI,SAAS,QAAQ,KAAM,EAAE,IAAMC,GAE/C,CAAC,IAAI,OAAOC,CAAQ,EAAE,KAAKF,EAAI,QAAQ,GAEvCG,GAAQ,CAAC,IAAI,OAAOA,CAAI,EAAE,KAAKH,EAAI,IAAI,GAEvCI,GAAY,CAAC,IAAI,OAAOA,CAAQ,EAAE,KAAKJ,EAAI,QAAQ"}