mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-27 18:06:39 +02:00
fix url regax pattern.
This commit is contained in:
@@ -59,7 +59,7 @@ 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)
|
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(
|
||||||
@@ -183,7 +183,7 @@ class RichTextParser() {
|
|||||||
} else if (word.contains(".") && schemelessMatcher.find()) {
|
} else if (word.contains(".") && schemelessMatcher.find()) {
|
||||||
val url = schemelessMatcher.group(1) // url
|
val url = schemelessMatcher.group(1) // url
|
||||||
val additionalChars = schemelessMatcher.group(4) // additional chars
|
val additionalChars = schemelessMatcher.group(4) // additional chars
|
||||||
val pattern = "^([A-Za-z0-9-_]+(\\.[A-Za-z0-9-_]+)+)(:[0-9]+)?(/[^?#]*)?(\\?[^#]*)?(#.*)?".toRegex(RegexOption.IGNORE_CASE)
|
val pattern = """^([A-Za-z0-9-_]+(\.[A-Za-z0-9-_]+)+)(:[0-9]+)?(/[^?#]*)?(\?[^#]*)?(#.*)?""".toRegex(RegexOption.IGNORE_CASE)
|
||||||
if (pattern.find(word) != null) {
|
if (pattern.find(word) != null) {
|
||||||
SchemelessUrlSegment(word, url, additionalChars)
|
SchemelessUrlSegment(word, url, additionalChars)
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user