node_modules/gulp-uncss/node_modules/uncss/lib/lib.js
/**
 * Parse paths relatives to a source.
 * @param  {String} source      Where the paths originate from
 * @param  {Array}  stylesheets List of paths
 * @param  {Object} options     Options, as passed to UnCSS
 * @return {Array}              List of paths
 */
Parse paths relatives to a source.
@param  {String} source      Where the paths originate from
@param  {Array}  stylesheets List of paths
@param  {Object} options     Options, as passed to UnCSS
@return {Array}              List of paths
Parse paths relatives to a source . @param { String } source Where the paths originate from @param { Array } stylesheets List of paths @param { Object } options Options as passed to UnCSS @return { Array } List of paths
function parsePaths(source, stylesheets, options) {
    return stylesheets.map(function (sheet) {
        var _url, _path, _protocol;
        if (sheet.substr(0, 4) === 'http') {
            return sheet;
        }
        if (source.match(/^http/)) {
            _url      = url.parse(source);
            _protocol = _url.protocol;
        }
        if (sheet.substr(0, 2) === '//') {
            return (_protocol ? _protocol + sheet : 'http:' + sheet);
        }
        if (_url) {
            _path = url.resolve(source, sheet);
        } else {
            sheet = sheet.split('?')[0].split('#')[0];
            if (sheet[0] === '/' && options.htmlroot) {
                _path = path.join(options.htmlroot, sheet);
            } else {
                _path = path.join(path.dirname(source), options.csspath, sheet);
            }
        }
        return _path;
    });
}
function parsePaths ( source , stylesheets , options ) { return stylesheets . map ( function ( sheet ) { var _url , _path , _protocol ; if ( sheet . substr ( 0 , 4 ) === 'http' ) { return sheet ; } if ( source . match ( / ^http / ) ) { _url = url . parse ( source ) ; _protocol = _url . protocol ; } if ( sheet . substr ( 0 , 2 ) === '//' ) { return ( _protocol ? _protocol + sheet : 'http:' + sheet ) ; } if ( _url ) { _path = url . resolve ( source , sheet ) ; } else { sheet = sheet . split ( '?' ) [ 0 ] . split ( '#' ) [ 0 ] ; if ( sheet [ 0 ] === '/' && options . htmlroot ) { _path = path . join ( options . htmlroot , sheet ) ; } else { _path = path . join ( path . dirname ( source ) , options . csspath , sheet ) ; } } return _path ; } ) ; }
Parse paths relatives to a source.
Parse paths relatives to a source .
/* No need to parse, it's already a valid path */ /* Check if we are fetching over http(s) */ /* Use the same protocol we used for fetching this page.
             * Default to http.
             */ /* Let the url module handle the parsing */ /* We are fetching local files
             * Should probably report an error if we find an absolute path and
             *   have no htmlroot specified.
             */ /* Fix the case when there is a query string or hash */