Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return str.every(s => {
if (is.url(s)) {
return s
}
// wait-on allows specifying HTTP verb to use instead of default HEAD
// and the format then is like "http-get://domain.com" to use GET
if (isWaitOnUrl(s)) {
return s
}
if (is.number(s)) {
return is.port(s)
}
if (!is.string(s)) {
return false
}
if (s[0] === ':') {
const withoutColon = s.substr(1)
function formAuthToken (registryUrl, tokenEnvName) {
if (!tokenEnvName) {
if (!process.env.NPM_TOKEN) {
throw new Error('Cannot find NPM_TOKEN\nuse ' + getNpmToken + ' to get one')
}
tokenEnvName = 'NPM_TOKEN'
}
la(is.url(registryUrl), 'npm registry should be an url', registryUrl)
// strip protocol http/https part
registryUrl = registryUrl.replace('https:', '')
registryUrl = registryUrl.replace('http:', '')
var line = registryUrl + ':_authToken='
var fullLine = line + '${' + tokenEnvName + '}'
return {
test: line,
token: fullLine
}
}
function getJustVersion (npmNameOrUrl) {
la(is.unemptyString(npmNameOrUrl), 'missing NPM string', npmNameOrUrl)
if (npmNameOrUrl.startsWith('cypress')) {
return npmNameOrUrl
}
if (is.url(npmNameOrUrl)) {
// try finding semver in the url
// https://something/0.20.3/something...
const re = /\/(\d+\.\d+\.\d+(-\w+)?)\//
const matches = re.exec(npmNameOrUrl)
if (matches) {
return matches[1]
}
}
return npmNameOrUrl
}
const _navigateUsingCRI = function (url) {
la(check.url(url), 'missing url to navigate to', url)
return function (client) {
la(client, 'could not get CRI client')
debug('received CRI client')
debug('navigating to page %s', url)
// when opening the blank page and trying to navigate
// the focus gets lost. Restore it and then navigate.
return client.send('Page.bringToFront')
.then(() => {
return client.send('Page.navigate', { url })
})
}
}
const formRepoUrl = (name) => {
if (is.url(name)) {
return name
}
if (hasOwnerAndName(name)) {
return `https://github.com/${name}.git`
} else {
return `https://github.com/cypress-io/${name}.git`
}
}
function findDeploy (url) {
la(is.url(url), 'expected url', url)
return nowPipeline.deployments()
.then(deploys => {
debug('looking for url %s in %d deploys', url, deploys.length)
const found = deploys.find(d => {
return url.endsWith(d.url)
})
if (!found) {
console.error('Could not find deploy for url', url)
process.exit(-1)
}
debug('found deployment', found)
return found
})
}
function isRepoUrl (s) {
return (is.git(s) || is.url(s)) && isGitHub(s)
}
const getUrl = (version) => {
if (is.url(version)) {
debug('version is already an url', version)
return version
}
return version ? prepend(`desktop/${version}`) : prepend('desktop')
}
const getUrl = (version) => {
if (is.url(version)) {
debug('version is already an url', version)
return version
}
return version ? prepend(`desktop/${version}`) : prepend('desktop')
}