fix: isWebBricksBackendResource() must extract path from full URLs before matching /public
Bug: when fetchUi('/public') resolves to http://host:port/public, the
isWebBricksBackendResource() check compared the full URL string against
'/public' and always returned false, so _webbricks_=1 was never added.
Fix: extract the path component from full URLs (strip scheme+host) before
running the .ui/.dspy/public/root detection logic. All HTTP methods
(getText/getJson/postJson/postForm) delegate to withBackendContextIfNeeded
which calls isWebBricksBackendResource, so this fix covers all code paths.
This commit is contained in:
parent
b7cffab3f9
commit
2b3dd84a13
@ -54,9 +54,21 @@ fun withWebBricksRequestContext(
|
||||
* Detect URLs that need WebBricks backend context (_webbricks_=1).
|
||||
* Covers both direct .ui/.dspy paths and index fallback paths that the
|
||||
* server resolves to .ui files (e.g. "/" → index.ui, "/public" → index.ui).
|
||||
*
|
||||
* Handles both full URLs (http://host:port/public) and path-only strings (/public).
|
||||
*/
|
||||
fun String.isWebBricksBackendResource(): Boolean {
|
||||
val path = substringBefore('?').substringBefore('#')
|
||||
val withoutQuery = substringBefore('?').substringBefore('#')
|
||||
|
||||
// Extract path component: strip scheme+host for full URLs, keep as-is for paths
|
||||
val path = if (withoutQuery.contains("://")) {
|
||||
// Full URL: find first '/' after "://"
|
||||
val afterScheme = withoutQuery.substringAfter("://")
|
||||
"/" + afterScheme.substringAfter('/', missingDelimiterValue = "")
|
||||
} else {
|
||||
withoutQuery
|
||||
}
|
||||
|
||||
val normalized = path.trimEnd('/')
|
||||
|
||||
// Direct .ui/.dspy resource
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user