Skip to content

Commit

Permalink
test: improve url parsing logic
Browse files Browse the repository at this point in the history
  • Loading branch information
guarmo committed Nov 6, 2024
1 parent efac420 commit 585f6ef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions demos/src/Marks/Link/React/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default () => {
validate: (url, ctx) => {
try {
// construct URL
const parsedUrl = url.startsWith('http') ? new URL(url) : new URL(`${ctx.defaultProtocol}://${url}`)
const parsedUrl = url.includes(':') ? new URL(url) : new URL(`${ctx.defaultProtocol}://${url}`)

// use default validation
if (!ctx.defaultValidate(parsedUrl.href)) {
Expand Down Expand Up @@ -63,7 +63,7 @@ export default () => {
shouldAutoLink: url => {
try {
// construct URL
const parsedUrl = url.startsWith('http') ? new URL(url) : new URL(`https://${url}`)
const parsedUrl = url.includes(':') ? new URL(url) : new URL(`https://${url}`)

// only auto-link if the domain is not in the disallowed list
const disallowedDomains = ['example-no-autolink.com', 'another-no-autolink.com']
Expand Down

0 comments on commit 585f6ef

Please sign in to comment.