Skip to content

Commit

Permalink
idもindexも全部まとめてマッチさせるように
Browse files Browse the repository at this point in the history
  • Loading branch information
mehm8128 committed Nov 30, 2023
1 parent 7aef0ac commit 363aef5
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions build/gen-mplus.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,11 @@ const generateFilename = font => {
const family = font['font-family'].replace(/[' ]/g, '')
const weight = font['font-weight'].replace(/[' ]/g, '')

const fontSrcWithIndex = getUrlFromSrc(font.src).match(
/\/v\d+\/[^.]+\.(\d+)\.woff2/
)
if (!fontSrcWithIndex) {
const fontSrcWithId = getUrlFromSrc(font.src).match(
/\/v\d+\/([^.]+)\.woff2/
)
if (!fontSrcWithId) {
throw new Error(`Unexpected URL: ${getUrlFromSrc(font.src)}`)
}
return `${family}.${weight}.${fontSrcWithId[1]}.woff2`
const fontSrcWithId = getUrlFromSrc(font.src).match(/\/v\d+\/(.+)\.woff2/)
if (!fontSrcWithId) {
throw new Error(`Unexpected URL: ${getUrlFromSrc(font.src)}`)
}
return `${family}.${weight}.${fontSrcWithIndex[1]}.woff2`
return `${family}.${weight}.${fontSrcWithId[1]}.woff2`
}

const downloadAndtransform = async (url, filename) => {
Expand Down

0 comments on commit 363aef5

Please sign in to comment.