plugins/imgurls-parse.js
function transform(file) {
    // Parses CSS file and turns it into a \n-separated img URLs.
    var data = file.contents.toString('utf-8');

    var matches = [];
    var match;
    while ((match = url_pattern.exec(data)) !== null) {
        var url = match[1];

        // Ensure it is an absolute URL (no relative URLs).
        var has_origin = url.search(/(https?):|\/\//) === 0 || url[0] === '/';
        if (!has_origin) {
            var absolute_path = path.join(MKT_CONFIG.CSS_DEST_PATH, url);
            url = '/' + path.relative('src', absolute_path);
        }

        if (img_urls.indexOf(url) === -1) {
            matches.push(url);
            img_urls.push(url);
        }
    }

    return matches.join('\n');
}
function transform(file) {
    // Parses CSS file and turns it into a \n-separated img URLs.
    var data = file.contents.toString('utf-8');

    var matches = [];
    var match;
    while ((match = url_pattern.exec(data)) !== null) {
        var url = match[1];

        // Ensure it is an absolute URL (no relative URLs).
        var has_origin = url.search(/(https?):|\/\//) === 0 || url[0] === '/';
        if (!has_origin) {
            var absolute_path = path.join(MKT_CONFIG.CSS_DEST_PATH, url);
            url = '/' + path.relative('src', absolute_path);
        }

        if (img_urls.indexOf(url) === -1) {
            matches.push(url);
            img_urls.push(url);
        }
    }

    return matches.join('\n');
}
function transform ( file ) { // Parses CSS file and turns it into a \n-separated img URLs. var data = file . contents . toString ( 'utf-8' ) ; var matches = [ ] ; var match ; while ( ( match = url_pattern . exec ( data ) ) !== null ) { var url = match [ 1 ] ; // Ensure it is an absolute URL (no relative URLs). var has_origin = url . search ( / (https?):|\/\/ / ) === 0 || url [ 0 ] === '/' ; if ( ! has_origin ) { var absolute_path = path . join ( MKT_CONFIG . CSS_DEST_PATH , url ) ; url = '/' + path . relative ( 'src' , absolute_path ) ; } if ( img_urls . indexOf ( url ) === - 1 ) { matches . push ( url ) ; img_urls . push ( url ) ; } } return matches . join ( '\n' ) ; }
Keep track of duplicates.
Keep track of duplicates .