Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-font-grabber

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-font-grabber - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

34

dist/lib/font-grabber.js

@@ -36,2 +36,4 @@ 'use strict';

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -94,3 +96,3 @@

return result === null ? null : _url2.default.parse(result[2]);
return result === null ? null : _url2.default.parse(result[1]);
}

@@ -166,3 +168,3 @@

return false;
} else if (regexes.isFontFaceSrcContainsRemoteUrlRegex.test(decl.value) === false) {
} else if (regexes.isFontFaceSrcContainsRemoteFontUrlRegex.test(decl.value) === false) {
return false;

@@ -175,2 +177,15 @@ }

/**
*
* @param urlSrcSources
* @param srcSource
* @returns {Array}
*/
}, {
key: 'keepUrlSrcSourceOnly',
value: function keepUrlSrcSourceOnly(urlSrcSources, srcSource) {
return regexes.isRemoteFontUrlRegex.test(srcSource) ? [].concat(_toConsumableArray(urlSrcSources), [srcSource]) : urlSrcSources;
}
/**
* Download font file and update output CSS rule correspondingly.

@@ -193,13 +208,14 @@ *

//
// One src could have multiple `url()`, they are separated with `,`.
// One src could have multiple `source`, they are separated with `,`,
// so break it down and filter out those which isn't an `url` source.
//
var srcUrls = decl.value.split(',').map(function (value) {
return value.replace(regexes.trimRegex, '');
});
var urlSrcSources = decl.value.split(',').map(function trim(srcSources) {
return srcSources.replace(regexes.trimRegex, '');
}).reduce(FontGrabber.keepUrlSrcSourceOnly, []);
//
// Use `srcUrls` to generate Url objects for download.
// Use `urlSrcSources` to generate Url objects for download.
// This will check the validation of font url, and only keep which is
// unique.
var fontFileUrlObjects = srcUrls.map(FontGrabber.generateUrlObjectFromSrc).reduce(FontGrabber.keepUniqueAndValidFontFileUrlObject, []);
var fontFileUrlObjects = urlSrcSources.map(FontGrabber.generateUrlObjectFromSrc).reduce(FontGrabber.keepUniqueAndValidFontFileUrlObject, []);

@@ -322,2 +338,2 @@ //

module.exports = exports['default'];
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvZm9udC1ncmFiYmVyLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7O0FBR0E7Ozs7QUFDQTs7OztBQUNBOzs7O0FBQ0E7O0lBQVksTzs7QUFDWjs7Ozs7Ozs7Ozs7Ozs7SUFNTSxXOzs7Ozs7Ozs7Ozs7OzJDQVUyQixXLEVBQWE7QUFDMUMsVUFBSSxDQUFFLFlBQVksSUFBbEIsRUFBd0I7QUFDdEIsY0FBTSxJQUFJLEtBQUosQ0FBVSxzREFBVixDQUFOO0FBQ0Q7QUFDRCxVQUFJLENBQUUsWUFBWSxFQUFsQixFQUFzQjtBQUNwQixjQUFNLElBQUksS0FBSixDQUFVLG9EQUFWLENBQU47QUFDRDtBQUNGOzs7Ozs7Ozs7Ozs7Ozt1Q0FPMEIsUSxFQUFVO0FBQ25DLGFBQU8sVUFBQyxJQUFELEVBQVU7QUFDZixhQUFLLElBQUwsQ0FBVSxRQUFWO0FBQ0QsT0FGRDtBQUdEOzs7Ozs7Ozs7OzZDQU9nQyxHLEVBQUs7QUFDcEMsVUFBTSxTQUFTLFFBQVEsOEJBQVIsQ0FBdUMsSUFBdkMsQ0FBNEMsR0FBNUMsQ0FBZjs7QUFFQSxhQUNFLFdBQVcsSUFBWCxHQUNBLElBREEsR0FFQSxjQUFJLEtBQUosQ0FBVSxPQUFPLENBQVAsQ0FBVixDQUhGO0FBS0Q7Ozs7Ozs7Ozs7O3dEQVEyQyxJLEVB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vbigpfVxuICAgKi9cbiAgc3RhdGljIG1ha2VGb250RG93bmxvYWRKb2JEaXNwYXRjaGVyIChkb3dubG9hZERpcikge1xuICAgIHJldHVybiAoZm9udFVybE9iaikgPT4ge1xuICAgICAgY29uc3QgZmlsZW5hbWUgPSBmb250VXJsT2JqLnBhdGhuYW1lLnNwbGl0KCcvJykucG9wKCk7XG4gICAgICBcbiAgICAgIHJldHVybiB7XG4gICAgICAgIHVybCAgICAgOiBmb250VXJsT2JqLmhyZWYsXG4gICAgICAgIGZpbGVuYW1lOiBmaWxlbmFtZSxcbiAgICAgICAgcHJvbWlzZSA6IEZvbnRHcmFiYmVyLmRvd25sb2FkZXIuZG93bmxvYWQoXG4gICAgICAgICAgZm9udFVybE9iaixcbiAgICAgICAgICBwYXRoLmpvaW4oZG93bmxvYWREaXIsIGZpbGVuYW1lKVxuICAgICAgICApLFxuICAgICAgfTtcbiAgICB9O1xuICB9XG4gIFxuICAvKipcbiAgICpcbiAgICogQHBhcmFtIG9wdHNcbiAgICogQHBhcmFtIHBvc3Rjc3NPcHRzXG4gICAqL1xuICBzdGF0aWMgcmV2aWV3T3B0aW9ucyAob3B0cywgcG9zdGNzc09wdHMpIHtcbiAgICBpZiAoISBvcHRzLmRpclBhdGgpIHtcbiAgICAgIG9wdHMuZGlyUGF0aCA9IHBhdGguZGlybmFtZShwb3N0Y3NzT3B0cy50byk7XG4gICAgfVxuICB9XG4gIFxuICAvKipcbiAgICogU2tpcCBGb250LUZhY2UgUG9zdGNzcyBvYmplY3QgdGhhdCBpczpcbiAgICogICBub3QgYSBEZWNsYXJhdGlvblxuICAgKiAgIG9yIGRvZXNuJ3QgY29udGFpbiBgc3JjYCBwcm9wZXJ0eVxuICAgKiAgIG9yIGRvZXNuJ3QgY29udGFpbiByZW1vdGUgZm9udCBmaWxlXG4gICAqXG4gICAqIEBwYXJhbSBkZWNsXG4gICAqIEByZXR1cm5zIHtib29sZWFufVxuICAgKi9cbiAgc3RhdGljIHNob3VsZFByb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seS5cbiAgICAgIC8vXG4gICAgICBsZXQgcHJvY2Vzc1Byb21pc2VzID0gW107XG4gICAgICBcbiAgICAgIGNvbnN0IGRlY2xhcmF0aW9uUHJvY2Vzc29yID0gKGRlY2wpID0+IHtcbiAgICAgICAgaWYgKEZvbnRHcmFiYmVyLnNob3VsZFByb2Nlc3NUaGlzRm9udEZhY2VEZWNsYXJhdGlvbihkZWNsKSkge1xuICAgICAgICAgIHByb2Nlc3NQcm9taXNlcy5wdXNoKFxuICAgICAgICAgICAgRm9udEdyYWJiZXIuZG93bmxvYWRGb250QW5kVXBkYXRlRGVjbGFyYXRpb24oZGVjbCwgb3B0cy5kaXJQYXRoLCBwb3N0Y3NzT3B0cy50bylcbiAgICAgICAgICApO1xuICAgICAgICB9XG4gICAgICB9O1xuICAgICAgXG4gICAgICBjc3Mud2Fsa0F0UnVsZXMoL2ZvbnQtZmFjZS8sIEZvbnRHcmFiYmVyLml0ZXJhdGVDU1NSdWxlV2l0aChkZWNsYXJhdGlvblByb2Nlc3NvcikpO1xuICAgICAgXG4gICAgICByZXR1cm4gKFxuICAgICAgICBwcm9jZXNzUHJvbWlzZXMubGVuZ3RoID09PSAwID9cbiAgICAgICAgICBQcm9taXNlLnJlc29sdmUoKSA6XG4gICAgICAgICAgUHJvbWlzZS5hbGwocHJvY2Vzc1Byb21pc2VzKVxuICAgICAgKTtcbiAgICB9O1xuICB9XG59XG5cbmV4cG9ydCBkZWZhdWx0IEZvbnRHcmFiYmVyOyJdfQ==

@@ -10,6 +10,7 @@ "use strict";

var extractUrlFromFontFaceSrcRegex = /^url\s*\(\s*(\"|\')(https?:[^\)]*?)(\"|\')\s*\)/;
var extractUrlFromFontFaceSrcRegex = /^url\s*\(\s*[\'\"]?(https?:[^\)]*?)[\'\"]?\s*\)/;
var validFontExtensionRegex = /\.(ttf|otf|woff|eot|svg)$/;
var trimRegex = /(^\s+|\s+$)/g;
var isFontFaceSrcContainsRemoteUrlRegex = /^\s*url\s*\(\s*(\'|\"https?:)/;
var isFontFaceSrcContainsRemoteFontUrlRegex = /(\s*|,|^)url\s*\(\s*[\'\"]?https?:/;
var isRemoteFontUrlRegex = /^\s*url\s*\(\s*[\'\"]?https?:/;

@@ -19,3 +20,4 @@ exports.extractUrlFromFontFaceSrcRegex = extractUrlFromFontFaceSrcRegex;

exports.trimRegex = trimRegex;
exports.isFontFaceSrcContainsRemoteUrlRegex = isFontFaceSrcContainsRemoteUrlRegex;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvcmVnZXhlcy5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFJQSxJQUFNLGlDQUFzQyxpREFBNUM7QUFDQSxJQUFNLDBCQUFzQywyQkFBNUM7QUFDQSxJQUFNLFlBQXNDLGNBQTVDO0FBQ0EsSUFBTSxzQ0FBc0MsK0JBQTVDOztRQUdFLDhCLEdBQUEsOEI7UUFDQSx1QixHQUFBLHVCO1FBQ0EsUyxHQUFBLFM7UUFDQSxtQyxHQUFBLG1DIiwiZmlsZSI6InJlZ2V4ZXMuanMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIERlZmluZSBhbGwgcmVndWxhciBleHByZXNzaW9ucyB3aWxsIGJlIHVzZWQuXG4gKi9cblxuY29uc3QgZXh0cmFjdFVybEZyb21Gb250RmFjZVNyY1JlZ2V4ICAgICAgPSAvXnVybFxccypcXChcXHMqKFxcXCJ8XFwnKShodHRwcz86W15cXCldKj8pKFxcXCJ8XFwnKVxccypcXCkvO1xuY29uc3QgdmFsaWRGb250RXh0ZW5zaW9uUmVnZXggICAgICAgICAgICAgPSAvXFwuKHR0ZnxvdGZ8d29mZnxlb3R8c3ZnKSQvO1xuY29uc3QgdHJpbVJlZ2V4ICAgICAgICAgICAgICAgICAgICAgICAgICAgPSAvKF5cXHMrfFxccyskKS9nO1xuY29uc3QgaXNGb250RmFjZVNyY0NvbnRhaW5zUmVtb3RlVXJsUmVnZXggPSAvXlxccyp1cmxcXHMqXFwoXFxzKihcXCd8XFxcImh0dHBzPzopLztcblxuZXhwb3J0IHtcbiAgZXh0cmFjdFVybEZyb21Gb250RmFjZVNyY1JlZ2V4LFxuICB2YWxpZEZvbnRFeHRlbnNpb25SZWdleCxcbiAgdHJpbVJlZ2V4LFxuICBpc0ZvbnRGYWNlU3JjQ29udGFpbnNSZW1vdGVVcmxSZWdleCxcbn07XG4iXX0=
exports.isFontFaceSrcContainsRemoteFontUrlRegex = isFontFaceSrcContainsRemoteFontUrlRegex;
exports.isRemoteFontUrlRegex = isRemoteFontUrlRegex;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9saWIvcmVnZXhlcy5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFJQSxJQUFNLGlDQUEwQyxpREFBaEQ7QUFDQSxJQUFNLDBCQUEwQywyQkFBaEQ7QUFDQSxJQUFNLFlBQTBDLGNBQWhEO0FBQ0EsSUFBTSwwQ0FBMEMsb0NBQWhEO0FBQ0EsSUFBTSx1QkFBMEMsK0JBQWhEOztRQUdFLDhCLEdBQUEsOEI7UUFDQSx1QixHQUFBLHVCO1FBQ0EsUyxHQUFBLFM7UUFDQSx1QyxHQUFBLHVDO1FBQ0Esb0IsR0FBQSxvQiIsImZpbGUiOiJyZWdleGVzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBEZWZpbmUgYWxsIHJlZ3VsYXIgZXhwcmVzc2lvbnMgd2lsbCBiZSB1c2VkLlxuICovXG5cbmNvbnN0IGV4dHJhY3RVcmxGcm9tRm9udEZhY2VTcmNSZWdleCAgICAgICAgICA9IC9edXJsXFxzKlxcKFxccypbXFwnXFxcIl0/KGh0dHBzPzpbXlxcKV0qPylbXFwnXFxcIl0/XFxzKlxcKS87XG5jb25zdCB2YWxpZEZvbnRFeHRlbnNpb25SZWdleCAgICAgICAgICAgICAgICAgPSAvXFwuKHR0ZnxvdGZ8d29mZnxlb3R8c3ZnKSQvO1xuY29uc3QgdHJpbVJlZ2V4ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgID0gLyheXFxzK3xcXHMrJCkvZztcbmNvbnN0IGlzRm9udEZhY2VTcmNDb250YWluc1JlbW90ZUZvbnRVcmxSZWdleCA9IC8oXFxzKnwsfF4pdXJsXFxzKlxcKFxccypbXFwnXFxcIl0/aHR0cHM/Oi87XG5jb25zdCBpc1JlbW90ZUZvbnRVcmxSZWdleCAgICAgICAgICAgICAgICAgICAgPSAvXlxccyp1cmxcXHMqXFwoXFxzKltcXCdcXFwiXT9odHRwcz86LztcblxuZXhwb3J0IHtcbiAgZXh0cmFjdFVybEZyb21Gb250RmFjZVNyY1JlZ2V4LFxuICB2YWxpZEZvbnRFeHRlbnNpb25SZWdleCxcbiAgdHJpbVJlZ2V4LFxuICBpc0ZvbnRGYWNlU3JjQ29udGFpbnNSZW1vdGVGb250VXJsUmVnZXgsXG4gIGlzUmVtb3RlRm9udFVybFJlZ2V4LFxufTtcbiJdfQ==
{
"name": "postcss-font-grabber",
"version": "1.0.5",
"version": "1.0.6",
"description": "Grab remote font in @font-face, download it and update your CSS, end of story.",

@@ -5,0 +5,0 @@ "author": "AaronJan <aaronjan@qq.com>",

@@ -19,3 +19,3 @@ /**

static downloader = new Downloader();
/**

@@ -33,3 +33,3 @@ *

}
/**

@@ -45,3 +45,3 @@ *

}
/**

@@ -54,10 +54,10 @@ *

const result = regexes.extractUrlFromFontFaceSrcRegex.exec(src);
return (
result === null ?
null :
url.parse(result[2])
null :
url.parse(result[1])
);
}
/**

@@ -77,6 +77,6 @@ *

}
return kept;
}
/**

@@ -90,3 +90,3 @@ *

const filename = fontUrlObj.pathname.split('/').pop();
return {

@@ -102,3 +102,3 @@ url : fontUrlObj.href,

}
/**

@@ -114,3 +114,3 @@ *

}
/**

@@ -130,10 +130,22 @@ * Skip Font-Face Postcss object that is:

return false;
} else if (regexes.isFontFaceSrcContainsRemoteUrlRegex.test(decl.value) === false) {
} else if (regexes.isFontFaceSrcContainsRemoteFontUrlRegex.test(decl.value) === false) {
return false;
}
return true;
}
/**
*
* @param urlSrcSources
* @param srcSource
* @returns {Array}
*/
static keepUrlSrcSourceOnly (urlSrcSources, srcSource) {
return regexes.isRemoteFontUrlRegex.test(srcSource) ?
[...urlSrcSources, srcSource] :
urlSrcSources;
}
/**
* Download font file and update output CSS rule correspondingly.

@@ -153,16 +165,20 @@ *

//
// One src could have multiple `url()`, they are separated with `,`.
// One src could have multiple `source`, they are separated with `,`,
// so break it down and filter out those which isn't an `url` source.
//
const srcUrls = decl.value
const urlSrcSources = decl.value
.split(',')
.map(value => value.replace(regexes.trimRegex, ''));
.map(function trim (srcSources) {
return srcSources.replace(regexes.trimRegex, '');
})
.reduce(FontGrabber.keepUrlSrcSourceOnly, []);
//
// Use `srcUrls` to generate Url objects for download.
// Use `urlSrcSources` to generate Url objects for download.
// This will check the validation of font url, and only keep which is
// unique.
const fontFileUrlObjects = srcUrls
const fontFileUrlObjects = urlSrcSources
.map(FontGrabber.generateUrlObjectFromSrc)
.reduce(FontGrabber.keepUniqueAndValidFontFileUrlObject, []);
//

@@ -175,3 +191,3 @@ // If there is no font file needs to be download, end this function

}
//

@@ -188,3 +204,3 @@ // Download font to `saveDirPath` using Url objects **concurrently**

);
return Promise.all(jobs.map(job => job.promise))

@@ -201,3 +217,3 @@ .then(() => {

);
//

@@ -209,3 +225,3 @@ // Replace CSS rule with every font that downloaded.

job.url,
//

@@ -219,3 +235,3 @@ // Replace `\\` to `/` for Windows compatibility.

}
/**

@@ -228,3 +244,3 @@ *

}
/**

@@ -237,3 +253,3 @@ *

}
/**

@@ -251,3 +267,3 @@ * Make handle function for plugin to call with.

let postcssOpts = result.opts;
//

@@ -257,3 +273,3 @@ // If something is missing in the Postcss options, throw an Error.

FontGrabber.validatePostcssOptions(postcssOpts);
//

@@ -263,3 +279,3 @@ // Review options for Font Grabber (This may modify them).

FontGrabber.reviewOptions(opts, postcssOpts);
//

@@ -269,3 +285,3 @@ // Process every Declaration that matchs rule `font-face` concurrently.

let processPromises = [];
const declarationProcessor = (decl) => {

@@ -278,9 +294,9 @@ if (FontGrabber.shouldProcessThisFontFaceDeclaration(decl)) {

};
css.walkAtRules(/font-face/, FontGrabber.iterateCSSRuleWith(declarationProcessor));
return (
processPromises.length === 0 ?
Promise.resolve() :
Promise.all(processPromises)
Promise.resolve() :
Promise.all(processPromises)
);

@@ -287,0 +303,0 @@ };

@@ -5,6 +5,7 @@ /**

const extractUrlFromFontFaceSrcRegex = /^url\s*\(\s*(\"|\')(https?:[^\)]*?)(\"|\')\s*\)/;
const validFontExtensionRegex = /\.(ttf|otf|woff|eot|svg)$/;
const trimRegex = /(^\s+|\s+$)/g;
const isFontFaceSrcContainsRemoteUrlRegex = /^\s*url\s*\(\s*(\'|\"https?:)/;
const extractUrlFromFontFaceSrcRegex = /^url\s*\(\s*[\'\"]?(https?:[^\)]*?)[\'\"]?\s*\)/;
const validFontExtensionRegex = /\.(ttf|otf|woff|eot|svg)$/;
const trimRegex = /(^\s+|\s+$)/g;
const isFontFaceSrcContainsRemoteFontUrlRegex = /(\s*|,|^)url\s*\(\s*[\'\"]?https?:/;
const isRemoteFontUrlRegex = /^\s*url\s*\(\s*[\'\"]?https?:/;

@@ -15,3 +16,4 @@ export {

trimRegex,
isFontFaceSrcContainsRemoteUrlRegex,
isFontFaceSrcContainsRemoteFontUrlRegex,
isRemoteFontUrlRegex,
};

@@ -10,15 +10,15 @@ /**

'http://dummy.com',
execRegex(regexes.extractUrlFromFontFaceSrcRegex, 2, "url('http://dummy.com')")
execRegex(regexes.extractUrlFromFontFaceSrcRegex, 1, "url('http://dummy.com')")
);
t.is(
'http://dummy.com',
execRegex(regexes.extractUrlFromFontFaceSrcRegex, 2, "url ('http://dummy.com')")
execRegex(regexes.extractUrlFromFontFaceSrcRegex, 1, "url ('http://dummy.com')")
);
t.is(
'http://dummy.com',
execRegex(regexes.extractUrlFromFontFaceSrcRegex, 2, "url (\"http://dummy.com\")")
execRegex(regexes.extractUrlFromFontFaceSrcRegex, 1, "url (\"http://dummy.com\")")
);
t.is(
'https://dummy.com',
execRegex(regexes.extractUrlFromFontFaceSrcRegex, 2, "url ('https://dummy.com')")
execRegex(regexes.extractUrlFromFontFaceSrcRegex, 1, "url ('https://dummy.com')")
);

@@ -28,16 +28,20 @@

'http://dummy.com/dummy.html',
execRegex(regexes.extractUrlFromFontFaceSrcRegex, 2, "url('http://dummy.com/dummy.html')")
execRegex(regexes.extractUrlFromFontFaceSrcRegex, 1, "url('http://dummy.com/dummy.html')")
);
t.is(
'http://dummy.com/dummy.html',
execRegex(regexes.extractUrlFromFontFaceSrcRegex, 2, "url ('http://dummy.com/dummy.html')")
execRegex(regexes.extractUrlFromFontFaceSrcRegex, 1, "url ('http://dummy.com/dummy.html')")
);
t.is(
'http://dummy.com/dummy.html',
execRegex(regexes.extractUrlFromFontFaceSrcRegex, 2, "url (\"http://dummy.com/dummy.html\")")
execRegex(regexes.extractUrlFromFontFaceSrcRegex, 1, "url (\"http://dummy.com/dummy.html\")")
);
t.is(
'https://dummy.com/dummy.html',
execRegex(regexes.extractUrlFromFontFaceSrcRegex, 2, "url ('https://dummy.com/dummy.html')")
execRegex(regexes.extractUrlFromFontFaceSrcRegex, 1, "url ('https://dummy.com/dummy.html')")
);
t.is(
'https://fonts.gstatic.com/s/sourcesanspro/v9/toadOcfmlt9b38dHJxOBGLsbIrGiHa6JIepkyt5c0A0.ttf',
execRegex(regexes.extractUrlFromFontFaceSrcRegex, 1, 'url(https://fonts.gstatic.com/s/sourcesanspro/v9/toadOcfmlt9b38dHJxOBGLsbIrGiHa6JIepkyt5c0A0.ttf) format(\'truetype\')')
);
});

@@ -61,8 +65,9 @@

test('isFontFaceSrcContainsRemoteUrlRegex', t => {
t.true(regexes.isFontFaceSrcContainsRemoteUrlRegex.test("url('http://dummy.com')"));
t.true(regexes.isFontFaceSrcContainsRemoteUrlRegex.test("url('https://dummy.com')"));
t.true(regexes.isFontFaceSrcContainsRemoteUrlRegex.test('url("https://dummy.com")'));
t.true(regexes.isFontFaceSrcContainsRemoteUrlRegex.test(' url ("https://dummy.com")'));
t.true(regexes.isFontFaceSrcContainsRemoteUrlRegex.test(' url ( "https://dummy.com" )'));
test('isFontFaceSrcContainsRemoteFontUrlRegex', t => {
t.true(regexes.isFontFaceSrcContainsRemoteFontUrlRegex.test("url('http://dummy.com')"));
t.true(regexes.isFontFaceSrcContainsRemoteFontUrlRegex.test("url('https://dummy.com')"));
t.true(regexes.isFontFaceSrcContainsRemoteFontUrlRegex.test('url("https://dummy.com")'));
t.true(regexes.isFontFaceSrcContainsRemoteFontUrlRegex.test(' url ("https://dummy.com")'));
t.true(regexes.isFontFaceSrcContainsRemoteFontUrlRegex.test(' url ( "https://dummy.com" )'));
t.true(regexes.isFontFaceSrcContainsRemoteFontUrlRegex.test('local(\'Source Sans Pro Bold\'), local(\'SourceSansPro-Bold\'), url(https://fonts.gstatic.com/s/sourcesanspro/v9/toadOcfmlt9b38dHJxOBGLsbIrGiHa6JIepkyt5c0A0.ttf) format(\'truetype\')'));
});

@@ -69,0 +74,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc