Skip to content

Commit afddd1b

Browse files
mairasclaude
andcommitted
fix: keep resolveServerUrl null for non-absolute hrefs
isPath only rejected leading-slash paths, so schemeless hrefs like "foo/bar" were returned as-is and failed the existing "returns null for schemeless relative href" test. Gate on isAbsoluteUrl so any non-absolute href stays null server-side. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent c0a74ee commit afddd1b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

packages/common/src/url.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,15 @@ export const isAbsoluteUrl = (urlOrPath: string): boolean => {
5151

5252
/**
5353
* Resolves the URL used for server-side operations like pinging.
54-
* href might be path-only (e.g. "/cockpit/") which is not resolvable server-side
54+
* A non-absolute href (path-only like "/cockpit/" or schemeless like "foo/bar")
55+
* is not resolvable server-side, so it returns null.
5556
* @param app - object containing href and pingUrl properties
5657
* @returns the resolved URL as a string, or null if it cannot be resolved server-side
5758
*/
5859
export const resolveServerUrl = (app: { href: string | null; pingUrl: string | null }): string | null => {
5960
if (app.pingUrl) return app.pingUrl;
6061
if (!app.href) return null;
61-
if (isPath(app.href)) return null;
62+
if (!isAbsoluteUrl(app.href)) return null;
6263
return app.href;
6364
};
6465

0 commit comments

Comments
 (0)