lib/url-pattern/url-match-pattern.js
function (port, protocol) {
        var portRegex = this._matchPatternObject.port,

            // default port for given protocol
            defaultPort = protocol && DEFAULT_PROTOCOL_PORT[protocol];

        // return true if both given port and match pattern are absent
        if (typeof port === UNDEFINED && typeof portRegex === UNDEFINED) {
            return true;
        }

        // convert integer port to string
        (port && typeof port !== STRING) && (port = String(port));

        // assign default port or portRegex
        !port && (port = defaultPort);
        !portRegex && (portRegex = defaultPort);

        // matches * or specific port
        return (
            portRegex === MATCH_ALL ||
            portRegex === port
        );
    }
function (port, protocol) {
        var portRegex = this._matchPatternObject.port,

            // default port for given protocol
            defaultPort = protocol && DEFAULT_PROTOCOL_PORT[protocol];

        // return true if both given port and match pattern are absent
        if (typeof port === UNDEFINED && typeof portRegex === UNDEFINED) {
            return true;
        }

        // convert integer port to string
        (port && typeof port !== STRING) && (port = String(port));

        // assign default port or portRegex
        !port && (port = defaultPort);
        !portRegex && (portRegex = defaultPort);

        // matches * or specific port
        return (
            portRegex === MATCH_ALL ||
            portRegex === port
        );
    }
function ( port , protocol ) { var portRegex = this . _matchPatternObject . port , // default port for given protocol defaultPort = protocol && DEFAULT_PROTOCOL_PORT [ protocol ] ; // return true if both given port and match pattern are absent if ( typeof port === UNDEFINED && typeof portRegex === UNDEFINED ) { return true ; } // convert integer port to string ( port && typeof port !== STRING ) && ( port = String ( port ) ) ; // assign default port or portRegex ! port && ( port = defaultPort ) ; ! portRegex && ( portRegex = defaultPort ) ; // matches * or specific port return ( portRegex === MATCH_ALL || portRegex === port ) ; }
Tests if the current pattern allows the given port.

@param {String} port The port to be checked if the pattern allows.
@param {String} protocol Protocol to refer default port.
@return {Boolean}
Tests if the current pattern allows the given port .