Skip to content

Commit

Permalink
refactor: use localhost-url-regex (#299)
Browse files Browse the repository at this point in the history
instead of is-localhost-url since it's deprecated
  • Loading branch information
Kikobeats authored Mar 29, 2023
1 parent 1656b26 commit 2e7a8b1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/hover-vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
],
"dependencies": {
"@microlink/hover-react": "^5.5.14",
"is-localhost-url": "~1.0.3"
"localhost-url-regex": "~1.0.4"
},
"devDependencies": {
"@rollup/plugin-commonjs": "latest",
Expand Down
10 changes: 5 additions & 5 deletions packages/hover-vanilla/src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import ReactDOM from 'react-dom'
import styled from 'styled-components'
import MicrolinkHover from '@microlink/hover-react'
import isLocalhostUrl from 'is-localhost-url'
import localhostUrl from 'localhost-url-regex'
import styled from 'styled-components'
import ReactDOM from 'react-dom'
import React from 'react'

function toArray (selector) {
const collection = Array.from(
Expand All @@ -16,7 +16,7 @@ function toArray (selector) {
el.href = new URL(el.href).toString()
return el
})
.filter(el => el.href.startsWith('http') && !isLocalhostUrl(el.href))
.filter(el => el.href.startsWith('http') && !localhostUrl().test(el.href))
}

function parseJSON (value) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
],
"dependencies": {
"@microlink/mql": "~0.10.30",
"is-localhost-url": "~1.0.3",
"localhost-url-regex": "~1.0.4",
"nanoclamp": "~2.0.4"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fetchFromApi, getApiUrl as createApiUrl } from '@microlink/mql'
import isLocalhostUrl from 'is-localhost-url'
import localhostUrl from 'localhost-url-regex'
import { css } from 'styled-components'

export const isSSR = typeof window === 'undefined'
Expand Down Expand Up @@ -81,7 +81,7 @@ export const isLarge = cardSize => cardSize === 'large'
export const isSmall = cardSize => cardSize === 'small'

export const imageProxy = url =>
isLocalhostUrl(url)
localhostUrl().test(url)
? url
: `https://images.weserv.nl/?${new URLSearchParams({
url,
Expand Down

4 comments on commit 2e7a8b1

@vercel
Copy link

@vercel vercel bot commented on 2e7a8b1 Mar 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sdk-vanilla – ./packages/vanilla

sdk-vanilla.microlink.io
sdk-vanilla.vercel.app
sdk-vanilla-microlink.vercel.app
sdk-vanilla-git-master-microlink.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 2e7a8b1 Mar 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sdk-react – ./packages/react

sdk-react-microlink.vercel.app
sdk-react.vercel.app
sdk-react-git-master-microlink.vercel.app
sdk-react.microlink.io

@vercel
Copy link

@vercel vercel bot commented on 2e7a8b1 Mar 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sdk-hover-vanilla – ./packages/hover-vanilla

@vercel
Copy link

@vercel vercel bot commented on 2e7a8b1 Mar 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sdk-hover-react – ./

Please sign in to comment.