mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-23 15:39:28 -05:00
27e8c817d3
Co-authored-by: Jennifer Shehane <jennifer@cypress.io> Co-authored-by: Brian Mann <brian.mann86@gmail.com>
19 lines
477 B
TypeScript
19 lines
477 B
TypeScript
import _ from 'lodash'
|
|
import minimatch from 'minimatch'
|
|
import { stripProtocolAndDefaultPorts } from './uri'
|
|
|
|
export function matches (urlToCheck, blockHosts) {
|
|
// normalize into flat array
|
|
blockHosts = [].concat(blockHosts)
|
|
|
|
urlToCheck = stripProtocolAndDefaultPorts(urlToCheck)
|
|
|
|
// use minimatch against the url
|
|
// to see if any match
|
|
const matchUrl = (hostMatcher) => {
|
|
return minimatch(urlToCheck, hostMatcher)
|
|
}
|
|
|
|
return _.find(blockHosts, matchUrl)
|
|
}
|