Skip to content

Commit

Permalink
fix: prevent to proxify local urls
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Nov 25, 2019
1 parent a5a6bf7 commit 060d38a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/react/src/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { css } from 'styled-components'
import { fetchFromApi, getApiUrl as createApiUrl } from '@microlink/mql'

const REGEX_LOCALHOST = /http:\/\/localhost/

const isSSR = typeof window === 'undefined'

export const isFunction = fn => typeof fn === 'function'
Expand Down Expand Up @@ -60,7 +62,10 @@ export const isLarge = cardSize => cardSize === 'large'

export const isSmall = cardSize => cardSize === 'small'

export const imageProxy = url => `https://images.weserv.nl/?url=${encodeURI(url)}&l=9&af&il`
export const imageProxy = url =>
REGEX_LOCALHOST.test(url)
? url
: `https://images.weserv.nl/?url=${encodeURI(url)}&l=9&af&il`

export const isLazySupported = !isSSR && 'IntersectionObserver' in window

Expand Down

0 comments on commit 060d38a

Please sign in to comment.