You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
484 B
24 lines
484 B
8 years ago
|
const isURL = require('is-url')
|
||
|
|
||
|
exports.maybeURL = id => {
|
||
|
// E.g, "appname-asdf"
|
||
|
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)
|
||
|
}
|
||
|
|
||
|
// `url` should match the hostname of the deployment
|
||
|
u = u.replace(/^https:\/\//i, '')
|
||
|
|
||
|
if (!u.includes('.')) {
|
||
|
// `.now.sh` domain is implied if just the subdomain is given
|
||
|
u += '.now.sh'
|
||
|
}
|
||
|
|
||
|
return u
|
||
|
}
|