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.
26 lines
514 B
26 lines
514 B
|
|
'use strict';
|
|
|
|
|
|
module.exports = function format(url) {
|
|
var result = '';
|
|
|
|
result += url.protocol || '';
|
|
result += url.slashes ? '//' : '';
|
|
result += url.auth ? url.auth + '@' : '';
|
|
|
|
if (url.hostname && url.hostname.indexOf(':') !== -1) {
|
|
// ipv6 address
|
|
result += '[' + url.hostname + ']';
|
|
} else {
|
|
result += url.hostname || '';
|
|
}
|
|
|
|
result += url.port ? ':' + url.port : '';
|
|
result += url.pathname || '';
|
|
result += url.search || '';
|
|
result += url.hash || '';
|
|
|
|
return result;
|
|
};
|