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

[DEV-24810] uses URL api instead of string interpolation #66

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

diego-souza
Copy link

@diego-souza diego-souza commented Dec 5, 2024

DEV-24810

uses URL api instead of string interpolation

Previously URLs that already had parameters
would have two question marks "?"

I'll publish after merging and add it to the main project.

Previously URLs that already had parameters
would have two question marks "?"
@diego-souza diego-souza marked this pull request as ready for review December 5, 2024 18:22
@@ -9,6 +9,14 @@ export const toQuery = (object: Record<string, any>) => {
return searchParams ? `?${searchParams}` : ''
}

export const addParamsToUrl = (oldUrl: string, params: Record<string, any>) => {
const newUrl = new URL(oldUrl)
for (const [key, value] of params.entries()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is actually Record<string, any> then hashes do not posses methods, you should use Object.entries(params), if this is actually URLSearchParams then please type the argument as such

Copy link
Author

Choose a reason for hiding this comment

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

I'm following what comes from this:

export type BaseShareActionArgs = { shareUrl: string; utmParams?: Record<string, any>; teaser?: string }

I changed the entries call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants