Skip to content

fix: treat paths with https:// only in the query as relative - #2040

Open
alexcastgonz (pcbeingused333) wants to merge 1 commit into
microsoftgraph:mainfrom
pcbeingused333:fix/relative-path-embedded-https
Open

alexcastgonz (pcbeingused333) wants to merge 1 commit into
microsoftgraph:mainfrom
pcbeingused333:fix/relative-path-embedded-https

Conversation

@pcbeingused333

Copy link
Copy Markdown

Fixes #2039

Cause. GraphRequest.parsePath decided a path was an absolute URL with path.indexOf("https://") !== -1, so any relative path that merely contains https:// (for example in a query value) went down the absolute-URL branch, failed new URL(path) and threw GraphClientError: Unable to parse the URL. Examples: client.api("/sites?search=https://contoso.sharepoint.com"), /me/drive/root/search(q='https://example').

Fix. Only take the absolute-URL branch when the path starts with https://. The userinfo rejection and host/version extraction are unchanged.

Tests. Added cases to test/common/core/urlParsing.ts for relative paths with an embedded https://; they fail before the change and pass after. The rest of test/common/core still passes (113 passing).

Reproduction

client.api("/sites?search=https://contoso.sharepoint.com") throws before any HTTP request; expected URL https://graph.microsoft.com/v1.0/sites?search=https://contoso.sharepoint.com.


This change was prepared with the help of an AI coding assistant (Claude) and submitted by the account owner.

parsePath checked for https:// anywhere in the path, so relative paths such as
/sites?search=https://contoso.sharepoint.com were parsed as absolute URLs and
rejected. Only treat the path as absolute when it starts with https://.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant