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(jumpstart): generate link outside of firebase sdk #5149

Merged
merged 5 commits into from
Mar 27, 2024

Conversation

kathaypacific
Copy link
Collaborator

Description

As the title.

Test plan

Tested that the generated link is exactly the same as before this change.

Related issues

n/a

Backwards compatibility

n/a

Network scalability

n/a

Copy link

codecov bot commented Mar 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.80%. Comparing base (b6c340b) to head (1f1206e).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #5149   +/-   ##
=======================================
  Coverage   85.79%   85.80%           
=======================================
  Files         742      742           
  Lines       30097    30101    +4     
  Branches     5188     5188           
=======================================
+ Hits        25822    25828    +6     
+ Misses       4039     4037    -2     
  Partials      236      236           
Files Coverage Δ
src/firebase/dynamicLinks.ts 100.00% <100.00%> (+20.00%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b6c340b...1f1206e. Read the comment docs.

link: WEB_LINK,
})
)
const dynamicUrl = new URL(dynamicLink)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe i'm misunderstanding something here, but do we need to wrap this with another new URL constructor? isn't this essentially new URL(new URL(stuff...))?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops, i meant to remove that. thanks for the catch!

Comment on lines +38 to +44
// the firebase dynamic links sdk encodes dots and dashes even though it is
// not strictly required for urls. calling searchParams.set seems to transform
// __all__ search params to be url encoded, where dots and dashes are no
// longer encoded. This is probably okay, but to be extra safe we will put
// back the encoding ourselves.
const searchParams = dynamicUrl.search.replace(/\./g, '%2E').replace(/-/g, '%2D')
return `${dynamicUrl.origin}/${searchParams}`
Copy link
Member

Choose a reason for hiding this comment

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

Could we "not" be extra safe and remove this?
Feels a bit surprising we're only doing it for dots and dashes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i thought about this and tried consuming a link without the encoding on a simulator and it does work, but since the firebase sdk were producing links that are encoded in this way i thought it was safest to keep it incase somewhere in the sdk when consuming deep links on some specific devices, the encoding becomes important :/ since i don't understand why they did the encoding in the first place, i was thinking it wasn't worth the risk of removing it...at least this mess is well documented and inside this function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh the dots and dashes are hard coded because we know what the deep link will look like :)

@kathaypacific kathaypacific added this pull request to the merge queue Mar 27, 2024
Merged via the queue into main with commit 56df240 Mar 27, 2024
16 checks passed
@kathaypacific kathaypacific deleted the kathy/jumpstart-link-gen branch March 27, 2024 15:05
shottah pushed a commit to zed-io/kolektivo that referenced this pull request May 15, 2024
### Description

As the title.

### Test plan

Tested that the generated link is exactly the same as before this
change.

### Related issues

n/a

### Backwards compatibility

n/a

### Network scalability

n/a
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.

3 participants