Skip to content

Commit 79974d1

Browse files
authored
chore: remove no longer needed workaround for image cdn remote patterns limitation (#350)
1 parent e2737bc commit 79974d1

File tree

3 files changed

+2
-23
lines changed

3 files changed

+2
-23
lines changed

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
"path-to-regexp": "^6.2.1",
8282
"picomatch": "^3.0.1",
8383
"prettier": "^3.2.5",
84-
"regexp-tree": "^0.1.27",
8584
"semver": "^7.6.0",
8685
"typescript": "^5.1.6",
8786
"unionfs": "^4.5.1",

src/build/image-cdn.ts

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,10 @@
11
import type { RemotePattern } from 'next/dist/shared/lib/image-config.js'
22
import { makeRe } from 'picomatch'
3-
import { transform } from 'regexp-tree'
43

54
import { PluginContext } from './plugin-context.js'
65

7-
export function generateRegexFromPattern(pattern: string): string {
8-
const initialRegex = makeRe(pattern).source
9-
// resulting regex can contain lookaheads which currently cause problems with Netlify Image CDN remote patterns
10-
// so we strip them out
11-
// those regexes seems to be negative lookaheads for "dotfiles" / dots at the beginning of path segments
12-
// we actually are want to allow them and normally would pass dots: true option to `makeRe` function,
13-
// but this generally result in even more convoluted regular expression, so we just enable them via
14-
// stripping lookaheads
15-
16-
// Parse the regexp into an AST
17-
const re = transform(new RegExp(initialRegex), {
18-
Assertion(path) {
19-
// Remove the lookahead
20-
if (path.node.kind === 'Lookahead') {
21-
path.remove()
22-
}
23-
},
24-
})
25-
// Strip the leading and trailing slashes
26-
return re.toString().slice(1, -1)
6+
function generateRegexFromPattern(pattern: string): string {
7+
return makeRe(pattern).source
278
}
289

2910
/**

0 commit comments

Comments
 (0)