mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-28 21:53:01 +02:00
Moves HTTP regex compilation to outside the inner method
This commit is contained in:
@@ -59,6 +59,8 @@ val noProtocolUrlValidator = try {
|
|||||||
Pattern.compile("(([\\w\\d-]+\\.)*[a-zA-Z][\\w-]+[\\.\\:]\\w+([\\/\\?\\=\\&\\#\\.]?[\\w-]+)*\\/?)(.*)")
|
Pattern.compile("(([\\w\\d-]+\\.)*[a-zA-Z][\\w-]+[\\.\\:]\\w+([\\/\\?\\=\\&\\#\\.]?[\\w-]+)*\\/?)(.*)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val HTTPRegex = "^((http|https)://)?([A-Za-z0-9-]+(\\.[A-Za-z0-9]+)+)(:[0-9]+)?(/[^?#]*)?(\\?[^#]*)?(#.*)?".toRegex(RegexOption.IGNORE_CASE)
|
||||||
|
|
||||||
class RichTextParser() {
|
class RichTextParser() {
|
||||||
fun parseText(
|
fun parseText(
|
||||||
content: String,
|
content: String,
|
||||||
@@ -75,8 +77,7 @@ class RichTextParser() {
|
|||||||
} else if (it.originalUrl.contains("。")) {
|
} else if (it.originalUrl.contains("。")) {
|
||||||
null
|
null
|
||||||
} else {
|
} else {
|
||||||
val pattern = "^((http|https)://)?([A-Za-z0-9-]+(\\.[A-Za-z0-9]+)+)(:[0-9]+)?(/[^?#]*)?(\\?[^#]*)?(#.*)?".toRegex(RegexOption.IGNORE_CASE)
|
if (HTTPRegex.matches(it.originalUrl)) {
|
||||||
if (pattern.matches(it.originalUrl)) {
|
|
||||||
it.originalUrl
|
it.originalUrl
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
|
Reference in New Issue
Block a user