aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2018-05-07 17:28:22 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2018-07-14 23:57:12 +0300
commit4301503416ed45783a81250295adf4b5a86c4280 (patch)
tree43eb496b69803e2bab70c083420064ec28952fd3 /core/src
parent44ad68386658dde985207ea0aedb19c96d9b3f93 (diff)
downloaddokka-4301503416ed45783a81250295adf4b5a86c4280.tar.gz
dokka-4301503416ed45783a81250295adf4b5a86c4280.tar.bz2
dokka-4301503416ed45783a81250295adf4b5a86c4280.zip
[backport] KT-24299: Fix local links resolved in incorrect context
Original: fababd4
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/kotlin/Java/JavadocParser.kt14
-rw-r--r--core/src/main/kotlin/Model/Content.kt1
2 files changed, 14 insertions, 1 deletions
diff --git a/core/src/main/kotlin/Java/JavadocParser.kt b/core/src/main/kotlin/Java/JavadocParser.kt
index 8cd274e7..9f9ea017 100644
--- a/core/src/main/kotlin/Java/JavadocParser.kt
+++ b/core/src/main/kotlin/Java/JavadocParser.kt
@@ -12,6 +12,7 @@ import org.jsoup.Jsoup
import org.jsoup.nodes.Element
import org.jsoup.nodes.Node
import org.jsoup.nodes.TextNode
+import java.net.URI
data class JavadocParseResult(val content: Content, val deprecatedContent: Content?) {
companion object {
@@ -190,7 +191,18 @@ class JavadocParser(
}
element.hasAttr("href") -> {
val href = element.attr("href")
- ContentExternalLink(href)
+
+ val uri = try {
+ URI(href)
+ } catch (_: Exception) {
+ null
+ }
+
+ if (uri?.isAbsolute == false) {
+ ContentLocalLink(href)
+ } else {
+ ContentExternalLink(href)
+ }
}
element.hasAttr("name") -> {
ContentBookmark(element.attr("name"))
diff --git a/core/src/main/kotlin/Model/Content.kt b/core/src/main/kotlin/Model/Content.kt
index 4f142ca4..7c776bdb 100644
--- a/core/src/main/kotlin/Model/Content.kt
+++ b/core/src/main/kotlin/Model/Content.kt
@@ -149,6 +149,7 @@ class ContentExternalLink(val href : String) : ContentBlock() {
}
data class ContentBookmark(val name: String): ContentBlock()
+data class ContentLocalLink(val href: String) : ContentBlock()
class ContentUnorderedList() : ContentBlock()
class ContentOrderedList() : ContentBlock()