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

fontmin-webpack

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fontmin-webpack - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

.github/workflows/ci.yml

42

lib/index.js

@@ -13,5 +13,11 @@ const fs = require('fs')

const GLYPH_REGEX = /content\s*:[^};]*?('|")(.*?)\s*('|"|;)/g
const UNICODE_REGEX = /\\(\w{4})/
const UNICODE_REGEX = /\\([0-9a-f]{4,6})/i
const FONTMIN_EXTENSIONS = ['eot', 'woff', 'svg']
function getSurrogatePair(astralCodePoint) {
const highSurrogate = Math.floor((astralCodePoint - 0x10000) / 0x400) + 0xD800
const lowSurrogate = ((astralCodePoint - 0x10000) % 0x400) + 0xDC00
return [highSurrogate, lowSurrogate]
}
class FontminPlugin {

@@ -109,3 +115,15 @@ constructor(options) {

const unicodeMatch = match.match(UNICODE_REGEX)
return unicodeMatch ? String.fromCharCode(parseInt(unicodeMatch[1], 16)) : false
if (!unicodeMatch) {
return false
}
const unicodeHex = unicodeMatch[1]
const numericValue = parseInt(unicodeHex, 16)
const character = String.fromCharCode(numericValue)
if (unicodeHex.length === 4) {
return character
}
const multiCharacter = getSurrogatePair(numericValue)
.map(v => String.fromCharCode(v))
.join('')
return multiCharacter
})

@@ -178,9 +196,11 @@ .filter(Boolean)

return minifiableFonts.reduce((prev, group) => {
return prev.then(() => this.minifyFontGroup(group, glyphs)).then(files => {
files.forEach(file => {
if (file.buffer.length > file.minified.length) {
compilation.assets[file.asset] = new RawSource(file.minified)
}
return prev
.then(() => this.minifyFontGroup(group, glyphs))
.then(files => {
files.forEach(file => {
if (file.buffer.length > file.minified.length) {
compilation.assets[file.asset] = new RawSource(file.minified)
}
})
})
})
}, Promise.resolve())

@@ -192,2 +212,8 @@ }

compilation.hooks.additionalAssets.tapPromise('FontminPlugin', () => {
if (!compilation.modules || !compilation.assets) {
// eslint-disable-next-line no-console
console.warn(`[fontmin-webpack] Failed to detect modules. Check your webpack version!`)
return Promise.resolve()
}
return this.onAdditionalAssets(compilation)

@@ -194,0 +220,0 @@ })

29

package.json
{
"name": "fontmin-webpack",
"version": "3.0.0",
"version": "3.0.1",
"description": "Minifies icon fonts to just what is used.",

@@ -31,6 +31,6 @@ "main": "./lib/index.js",

"dependencies": {
"debug": "^3.0.1",
"fontmin": "^0.9.6",
"lodash": "^4.17.4",
"ttf2woff2": "^3.0.0",
"debug": "^4.3.1",
"fontmin": "^0.9.8",
"lodash": "^4.17.21",
"ttf2woff2": "^4.0.1",
"webpack-sources": "^2.2.0"

@@ -42,16 +42,17 @@ },

"devDependencies": {
"@mdi/font": "^5.9.55",
"@patrickhulce/lint": "^2.1.3",
"chai": "^4.1.1",
"css-loader": "^5.0.0",
"cz-conventional-changelog": "^2.0.0",
"chai": "^4.3.0",
"css-loader": "^5.0.2",
"cz-conventional-changelog": "^3.3.0",
"file-loader": "^6.2.0",
"font-awesome": "^4.7.0",
"html-webpack-plugin": "^4.5.0",
"mini-css-extract-plugin": "^1.2.1",
"mocha": "^3.2.0",
"rimraf": "^2.5.4",
"html-webpack-plugin": "^5.2.0",
"mini-css-extract-plugin": "^1.3.8",
"mocha": "^8.3.0",
"rimraf": "^3.0.2",
"style-loader": "^2.0.0",
"webpack": "^5.3.2",
"webpack-cli": "^4.1.0"
"webpack": "^5.24.1",
"webpack-cli": "^4.5.0"
}
}

@@ -17,4 +17,3 @@ const FontminPlugin = require('../../lib')

new MiniCssExtractPlugin({
filename: 'out.css',
allChunks: true,
filename: 'out.css'
}),

@@ -21,0 +20,0 @@ new HtmlWebpackPlugin(),

@@ -17,2 +17,3 @@ const fs = require('fs')

const baseExtractConfig = require('./fixtures/webpack.extract-text.config.js')
const baseUnicodeConfig = require('./fixtures/webpack.unicode.config.js')
const originalStats = collectFontStats(FONT_AWESOME_FOLDER + '/fonts', {

@@ -199,2 +200,11 @@ 'fontawesome-webfont.eot': true,

})
describe('FontAwesome with multi-byte unicode characters', () => {
it('should run successfully', function (done) {
this.timeout(60000)
testWithConfig(baseUnicodeConfig, done)
})
after(done => rimraf(DIST_FOLDER, done))
})
})
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