mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 17:35:16 +00:00
33 lines
524 B
JavaScript
33 lines
524 B
JavaScript
"use strict";
|
|
|
|
function parsePort(urlObj, options)
|
|
{
|
|
var defaultPort = -1;
|
|
|
|
for (var i in options.defaultPorts)
|
|
{
|
|
if ( i===urlObj.scheme && options.defaultPorts.hasOwnProperty(i) )
|
|
{
|
|
defaultPort = options.defaultPorts[i];
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (defaultPort > -1)
|
|
{
|
|
// Force same type as urlObj.port
|
|
defaultPort = defaultPort.toString();
|
|
|
|
if (urlObj.port === null)
|
|
{
|
|
urlObj.port = defaultPort;
|
|
}
|
|
|
|
urlObj.extra.portIsDefault = (urlObj.port === defaultPort);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
module.exports = parsePort;
|