|
|
|
@ -12,6 +12,9 @@ import org.jsoup.nodes.Document
|
|
|
|
import org.koitharu.kotatsu.parsers.InternalParsersApi
|
|
|
|
import org.koitharu.kotatsu.parsers.InternalParsersApi
|
|
|
|
import java.text.DateFormat
|
|
|
|
import java.text.DateFormat
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val REGEX_SCHEME_PREFIX = Regex("^\\w{2,6}://", RegexOption.IGNORE_CASE)
|
|
|
|
|
|
|
|
private const val SCHEME_HTTPS = "https"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Parse [Response] body as html document using Jsoup
|
|
|
|
* Parse [Response] body as html document using Jsoup
|
|
|
|
* @see [parseJson]
|
|
|
|
* @see [parseJson]
|
|
|
|
@ -76,10 +79,10 @@ public fun String.toRelativeUrl(domain: String): String {
|
|
|
|
* @return an absolute url with [domain] if this is relative
|
|
|
|
* @return an absolute url with [domain] if this is relative
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public fun String.toAbsoluteUrl(domain: String): String = when {
|
|
|
|
public fun String.toAbsoluteUrl(domain: String): String = when {
|
|
|
|
this.startsWith("//") -> "https:$this"
|
|
|
|
startsWith("//") -> "$SCHEME_HTTPS:$this"
|
|
|
|
this.startsWith('/') -> "https://$domain$this"
|
|
|
|
startsWith('/') -> "$SCHEME_HTTPS://$domain$this"
|
|
|
|
this.startsWith("https://") -> this
|
|
|
|
REGEX_SCHEME_PREFIX.containsMatchIn(this) -> this
|
|
|
|
else -> "https://$domain/$this"
|
|
|
|
else -> "$SCHEME_HTTPS://$domain/$this"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public fun concatUrl(host: String, path: String): String {
|
|
|
|
public fun concatUrl(host: String, path: String): String {
|
|
|
|
|