Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix trailing ? in URL of query builder #9216

Closed
wants to merge 1 commit into from

Conversation

Baltazore
Copy link
Collaborator

Description

Fix trailing ? in built url for query builder across json-api/rest/active-record

Mirage have troubles recognizing URL with trailing ?
I think other routers might have problems as well

Notes for the release

@@ -76,12 +76,14 @@ export function query(

copyForwardUrlOptions(urlOptions, options);

const url = buildBaseURL(urlOptions);
const url = new URL(buildBaseURL(urlOptions));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@runspired please let me know if this is good approach?

The only downside I see - it most likely append host in it.
Also it creates new instance of URL, not sure how performant it is.

const headers = new Headers();
headers.append('Accept', 'application/json;charset=utf-8');

return {
url: `${url}?${buildQueryParams(query, options.urlParamsSettings)}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead we should check if there is a query / check if buildQueryParams has output and use that to conditionally join with a ?

@runspired
Copy link
Contributor

Ended up porting the tests into #9220 with a modified approach there

@runspired runspired closed this Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants