Skip to content

Commit

Permalink
Fix privacy setting not respected during image detection in client
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzyis committed Sep 25, 2023
1 parent f6bd04f commit 7868f37
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
16 changes: 10 additions & 6 deletions components/image.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions components/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default memo(function Text ({ topLevel, noFragments, nofollow, imgproxyUr

const HeadingWrapper = (props) => Heading({ topLevel, slugger, noFragments, ...props })

const imgUrlCache = useImgUrlCache(children)
const imgUrlCache = useImgUrlCache(children, imgproxyUrls)

return (
<div className={styles.text}>
Expand Down Expand Up @@ -110,7 +110,9 @@ export default memo(function Text ({ topLevel, noFragments, nofollow, imgproxyUr

if (imgUrlCache[href] === IMG_CACHE_STATES.LOADED) {
const url = IMGPROXY_URL_REGEXP.test(href) ? decodeOriginalUrl(href) : href
const srcSet = imgproxyUrls ? imgproxyUrls[url] : undefined
// if `srcSet` is undefined, it means there image was not processed by worker yet
// if `srcSet` is null, image was processed but this specific url was not detected as an image by the worker
const srcSet = imgproxyUrls ? (imgproxyUrls[url] || null) : undefined
return <ZoomableImage topLevel={topLevel} srcSet={srcSet} {...props} src={href} />
}

Expand All @@ -136,7 +138,9 @@ export default memo(function Text ({ topLevel, noFragments, nofollow, imgproxyUr
},
img: ({ node, src, ...props }) => {
const url = IMGPROXY_URL_REGEXP.test(src) ? decodeOriginalUrl(src) : src
const srcSet = imgproxyUrls ? imgproxyUrls[url] : undefined
// if `srcSet` is undefined, it means there image was not processed by worker yet
// if `srcSet` is null, image was processed but this specific url was not detected as an image by the worker
const srcSet = imgproxyUrls ? (imgproxyUrls[url] || null) : undefined
return <ZoomableImage topLevel={topLevel} srcSet={srcSet} src={src} {...props} />
}
}}
Expand Down

0 comments on commit 7868f37

Please sign in to comment.