Skip to content

Commit

Permalink
Make link check lenient
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalp committed Apr 18, 2023
1 parent 8278c78 commit 6c60b8c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 22 deletions.
7 changes: 1 addition & 6 deletions frontend/src/components/MarkupEditor/MarkupImageModal.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react"
import modal from "../../services/modal"
import isUrl from "../../utils/is-url"
import FormGroup from "../form-group"
import isUrl from "./isUrl"
import { replaceSelection } from "./operations"

class MarkupImageModal extends React.Component {
Expand Down Expand Up @@ -30,11 +30,6 @@ class MarkupImageModal extends React.Component {
return false
}

if (!isUrl(url)) {
this.setState({ error: gettext("Enter a valid address.") })
return false
}

if (text.length > 0) {
replaceSelection(selection, update, "![" + text + "](" + url + ")")
} else {
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/components/MarkupEditor/MarkupLinkModal.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react"
import modal from "../../services/modal"
import isUrl from "../../utils/is-url"
import FormGroup from "../form-group"
import isUrl from "./isUrl"
import { replaceSelection } from "./operations"

class MarkupLinkModal extends React.Component {
Expand Down Expand Up @@ -30,11 +30,6 @@ class MarkupLinkModal extends React.Component {
return false
}

if (!isUrl(url)) {
this.setState({ error: gettext("Enter a valid address.") })
return false
}

if (text.length > 0) {
replaceSelection(selection, update, "[" + text + "](" + url + ")")
} else {
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/components/MarkupEditor/isUrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const URL_PATTERN = new RegExp("^(((ftps?)|(https?))://)", "i")

export default function isUrl(str) {
return URL_PATTERN.test(str.trim())
}
8 changes: 0 additions & 8 deletions frontend/src/utils/is-url.js

This file was deleted.

2 changes: 1 addition & 1 deletion misago/static/misago/js/misago.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion misago/static/misago/js/misago.js.map

Large diffs are not rendered by default.

0 comments on commit 6c60b8c

Please sign in to comment.