Skip to content

Commit

Permalink
always strip trailing /
Browse files Browse the repository at this point in the history
  • Loading branch information
nkzawa authored and leo committed May 2, 2017
1 parent eb48779 commit 9889a3b
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/utils/url.js
@@ -1,23 +1,21 @@
const isURL = require('is-url')

exports.maybeURL = id => {
// E.g, "appname-asdf"
return id.includes('-')
}
return id.includes('-');
};

exports.normalizeURL = u => {
// Normalize URL by removing slash from the end
if (isURL(u) && u.slice(-1) === '/') {
u = u.slice(0, -1)
if (u.slice(-1) === '/') {
u = u.slice(0, -1);
}

// `url` should match the hostname of the deployment
u = u.replace(/^https:\/\//i, '')
u = u.replace(/^https:\/\//i, '');

if (!u.includes('.')) {
// `.now.sh` domain is implied if just the subdomain is given
u += '.now.sh'
u += '.now.sh';
}

return u
}
return u;
};

0 comments on commit 9889a3b

Please sign in to comment.