]> uap-core.de Git - rssreader.git/commitdiff
fix baseUri when loading content in the webview
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 9 Jun 2026 15:01:07 +0000 (17:01 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 9 Jun 2026 15:01:07 +0000 (17:01 +0200)
rss-application/src/main/kotlin/de/unixwork/rssreader/FeedList.kt

index aa4e7618c8a2fdbcd9d153596703f8006a923c4c..194fe1f015fc17ff0d997a8b1fb2b037f0788637 100644 (file)
@@ -7,6 +7,7 @@ import de.unixwork.ui.kotlin.ToolkitDispatcher
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.GlobalScope
 import kotlinx.coroutines.launch
+import java.net.URI
 import java.time.ZoneId
 import java.time.format.DateTimeFormatter
 
@@ -219,13 +220,20 @@ class FeedList(window: MainWindow) : Document() {
 
     fun updateWebView() {
         currentItem?.let { item ->
+            var baseUri = item.link
+            try {
+                val linkUri = URI(item.link)
+                baseUri = URI(linkUri.scheme, linkUri.userInfo, linkUri.host, linkUri.port, linkUri.path, null, null).toString()
+            } catch (e: Exception) {
+                e.printStackTrace()
+            }
             if(browser.booleanValue()) {
                 webview.loadUrl(item.link)
                 // TODO: enable when more browser features (go prev/next) are implemented
                 //window.window.ui.setState(MainWindow.ITEM_INTERNAL_BROWSER)
             } else {
                 val content = item.getContent()
-                webview.loadContent(item.link, content.text, content.type, "utf-8")
+                webview.loadContent(baseUri, content.text, content.type, "utf-8")
                 window.window.unsetState(MainWindow.ITEM_INTERNAL_BROWSER)
             }
         }