Fix issue with site loading on older versions of Safari (#10077)
This commit is contained in:
@@ -36,12 +36,14 @@ export type ImgproxyPreset =
|
||||
| 'feed_thumbnail'
|
||||
| 'download'
|
||||
|
||||
// Using capturing groups here instead of lookbehinds in order to support older versions of Safari.
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=174931
|
||||
const IMGPROXY_PRESET_RE =
|
||||
/(?<=\/img\/)(default|avatar_thumbnail|avatar|banner|feed_fullsize|feed_thumbnail|download)(?=\/)/
|
||||
/(\/img\/)(default|avatar_thumbnail|avatar|banner|feed_fullsize|feed_thumbnail|download)(\/)/
|
||||
|
||||
/**
|
||||
* Replaces any imgproxy preset in a CDN URI with the given preset.
|
||||
*/
|
||||
export function convertCdnPreset(uri: string, preset: ImgproxyPreset): string {
|
||||
return uri.replace(IMGPROXY_PRESET_RE, preset)
|
||||
return uri.replace(IMGPROXY_PRESET_RE, `$1${preset}$3`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user