From 4a5de7321a04902b39de443faefcbf6295c492c4 Mon Sep 17 00:00:00 2001 From: Leo Lamprecht Date: Mon, 28 Nov 2016 11:36:03 +0100 Subject: [PATCH] Much stricter repo URL checking --- bin/now-deploy.js | 2 +- lib/github.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/now-deploy.js b/bin/now-deploy.js index 73db937..0df1a5f 100755 --- a/bin/now-deploy.js +++ b/bin/now-deploy.js @@ -229,7 +229,7 @@ async function sync(token) { // once the deployment has finished Object.assign(gitHubRepo, repo) } else if (isValidRepo === 'no-valid-url') { - stopDeployment(`URL is no valid repository from GitHub or GitLab.`) + stopDeployment(`This URL is not a valid repository from GitHub or GitLab.`) } else if (isValidRepo) { const gitRef = gitHubRepo.ref ? `with "${chalk.bold(gitHubRepo.ref)}" ` : '' stopDeployment(`There's no repository named "${chalk.bold(gitHubRepo.main)}" ${gitRef}on GitHub or GitLab`) diff --git a/lib/github.js b/lib/github.js index 234bcf6..3df8000 100644 --- a/lib/github.js +++ b/lib/github.js @@ -90,8 +90,8 @@ export const isRepoPath = path => { if (isURL(path)) { const urlParts = url.parse(path) - const slashCount = (urlParts.path.match(new RegExp('/', 'g')) || []).length - const notBare = slashCount >= 2 + const slashSplitted = urlParts.path.split('/').filter(n => n) + const notBare = slashSplitted.length >= 2 if (allowedHosts.includes(urlParts.host) && notBare) { return true