From 76e3afe88ea8221572dc5ace987bb84ac2405310 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Mon, 17 Oct 2016 17:17:47 -0700 Subject: [PATCH] remove: delete deployment by URL (#172) So this now works: ``` now rm https://ffitest-hcznbannyc.now.sh ``` Fixes #87. --- bin/now-remove | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/now-remove b/bin/now-remove index c787594..d776d2f 100755 --- a/bin/now-remove +++ b/bin/now-remove @@ -117,7 +117,18 @@ async function remove (token) { const deployments = await now.list(); const matches = deployments.filter((d) => { - return ids.find((id) => d.uid === id || d.name === id); + return ids.find((id) => { + // `url` should match the hostname of the deployment + let u = id.replace(/^https\:\/\//i, ''); + if (-1 === u.indexOf('.')) { + // `.now.sh` domain is implied if just the subdomain is given + u += '.now.sh'; + } + + return d.uid === id + || d.name === id + || d.url === u; + }); }); if (0 === matches.length) {