Removes top level domain number of char limitations to accept nostr: uris
This commit is contained in:
+1
-10
@@ -221,7 +221,6 @@ class DomainNameReader(
|
|||||||
|
|
||||||
lastWasAscii = isAscii
|
lastWasAscii = isAscii
|
||||||
} else if (index == 0) {
|
} else if (index == 0) {
|
||||||
println("First Char: $curr ${curr in UrlDetector.CANNOT_BEGIN_URLS_WITH}")
|
|
||||||
if (curr in UrlDetector.CANNOT_BEGIN_URLS_WITH) {
|
if (curr in UrlDetector.CANNOT_BEGIN_URLS_WITH) {
|
||||||
newStart = index + 1
|
newStart = index + 1
|
||||||
currentLabelLength = 0
|
currentLabelLength = 0
|
||||||
@@ -243,7 +242,6 @@ class DomainNameReader(
|
|||||||
buffer.clear()
|
buffer.clear()
|
||||||
buffer.append(current.substring(newStart))
|
buffer.append(current.substring(newStart))
|
||||||
|
|
||||||
|
|
||||||
// cut out the previous part, so now the domain name has to be from here.
|
// cut out the previous part, so now the domain name has to be from here.
|
||||||
startDomainName = 0
|
startDomainName = 0
|
||||||
}
|
}
|
||||||
@@ -301,7 +299,6 @@ class DomainNameReader(
|
|||||||
lastWasAscii = isAscii
|
lastWasAscii = isAscii
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (curr == '/') {
|
if (curr == '/') {
|
||||||
// continue by reading the path
|
// continue by reading the path
|
||||||
return checkDomainNameValid(ReaderNextState.ReadPath, curr)
|
return checkDomainNameValid(ReaderNextState.ReadPath, curr)
|
||||||
@@ -496,8 +493,7 @@ class DomainNameReader(
|
|||||||
buffer.substring(topStart, topStart + min(4, buffer.length - topStart))
|
buffer.substring(topStart, topStart + min(4, buffer.length - topStart))
|
||||||
|
|
||||||
// There is no size restriction if the top level domain is international (starts with "xn--")
|
// There is no size restriction if the top level domain is international (starts with "xn--")
|
||||||
valid =
|
valid = (topLevelStart.isXn() || topLevelLength >= MIN_TOP_LEVEL_DOMAIN)
|
||||||
((topLevelStart.isXn() || (topLevelLength in MIN_TOP_LEVEL_DOMAIN..MAX_TOP_LEVEL_DOMAIN)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
@@ -741,11 +737,6 @@ class DomainNameReader(
|
|||||||
*/
|
*/
|
||||||
private const val MIN_TOP_LEVEL_DOMAIN = 2
|
private const val MIN_TOP_LEVEL_DOMAIN = 2
|
||||||
|
|
||||||
/**
|
|
||||||
* The maximum length of a ascii based top level domain.
|
|
||||||
*/
|
|
||||||
private const val MAX_TOP_LEVEL_DOMAIN = 22
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum number that the url can be in a url that looks like:
|
* The maximum number that the url can be in a url that looks like:
|
||||||
* http://123123123123/path
|
* http://123123123123/path
|
||||||
|
|||||||
Reference in New Issue
Block a user