diff options
author | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2018-05-07 17:28:22 +0300 |
---|---|---|
committer | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2018-07-14 23:57:12 +0300 |
commit | 4301503416ed45783a81250295adf4b5a86c4280 (patch) | |
tree | 43eb496b69803e2bab70c083420064ec28952fd3 /core/src/main/kotlin/Java/JavadocParser.kt | |
parent | 44ad68386658dde985207ea0aedb19c96d9b3f93 (diff) | |
download | dokka-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/main/kotlin/Java/JavadocParser.kt')
-rw-r--r-- | core/src/main/kotlin/Java/JavadocParser.kt | 14 |
1 files changed, 13 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")) |