From d1ce432c65a93832e6a816f1a4d3a6b9523644d6 Mon Sep 17 00:00:00 2001 From: Leo Lamprecht Date: Fri, 10 Feb 2017 21:19:24 +0100 Subject: [PATCH] Normalize deployment URLs before removing This closes #299 --- bin/now-remove.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/now-remove.js b/bin/now-remove.js index bab2202..0912b9f 100755 --- a/bin/now-remove.js +++ b/bin/now-remove.js @@ -5,6 +5,7 @@ const minimist = require('minimist') const chalk = require('chalk') const ms = require('ms') const table = require('text-table') +const isURL = require('is-url') // Ours const Now = require('../lib') @@ -127,6 +128,11 @@ async function remove(token) { const matches = deployments.filter(d => { return ids.find(id => { + // Normalize URL by removing slash from the end + if (isURL(id) && id.slice(-1) === '/') { + id = id.slice(0, -1) + } + // `url` should match the hostname of the deployment let u = id.replace(/^https:\/\//i, '') @@ -139,6 +145,8 @@ async function remove(token) { }) }) + process.exit(0) + if (matches.length === 0) { error(`Could not find any deployments matching ${ids.map(id => chalk.bold(`"${id}"`)).join(', ')}. Run ${chalk.dim(`\`now ls\``)} to list.`) return process.exit(1)