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

(router): add url hash support #27105

Merged
merged 13 commits into from Mar 14, 2024
Merged

(router): add url hash support #27105

merged 13 commits into from Mar 14, 2024

Conversation

marklawlor
Copy link
Contributor

@marklawlor marklawlor commented Feb 15, 2024

Why

Adds URL hash support to Expo Router. This enable 3rd party services that use the hash as part of work flows (e.g authentication)

How

The hash is converted into a search parameter called #. This was chosen as its not a valid search parameter and the encoded version is unlikely to be in use.

Test Plan

Checklist

Copy link

linear bot commented Feb 15, 2024

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Feb 15, 2024
@marklawlor

This comment was marked as outdated.

it(`returns the pathname without hash for ${url}`, () => {
expect(getUrlWithReactNavigationConcessions(url).inputPathnameWithoutHash).toBe(expected);
});
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These were removed as inputPathnameWithoutHash isn't actually used in the code base and we not support hashes

@marklawlor marklawlor marked this pull request as ready for review February 29, 2024 02:50
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Feb 29, 2024
@marklawlor marklawlor force-pushed the marklawlor/router/ENG-6362 branch 2 times, most recently from 7134b17 to a384a1f Compare March 4, 2024 00:48
Copy link
Member

@amandeepmittal amandeepmittal left a comment

Choose a reason for hiding this comment

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

Docs changes lgtm 👍


The URL (hash)[https://developer.mozilla.org/en-US/docs/Web/API/URL/hash] is a string that follows the `#` symbol in a URL. It is commonly used on websites to link to a specific section of a page, but it can also be used to store data. Expo Router treats the hash as a special search parameter using the name `#`. It can be accessed and modified using the same hooks and APIs from [search parameters](/router/reference/search-parameters/).

```tsx app/hash.tsx
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
```tsx app/hash.tsx
```tsx app/index.tsx

@marklawlor
Copy link
Contributor Author

Comment out docs so they are not deployed

@marklawlor marklawlor merged commit 277b72c into main Mar 14, 2024
12 of 13 checks passed
@marklawlor marklawlor deleted the marklawlor/router/ENG-6362 branch March 14, 2024 06:04
amandeepmittal added a commit that referenced this pull request Mar 14, 2024
# Why

<!--
Please describe the motivation for this PR, and link to relevant GitHub
issues, forums posts, or feature requests.
-->

Follow-up #27105


# How

<!--
How did you build this feature or fix this bug and why?
-->

After confirming with @marklawlor, the "Hash support" section is
unversioned for now so we should hide it.

# Test Plan

<!--
Please describe how you tested this change and how a reviewer could
reproduce your test, especially if this PR does not include automated
tests! If possible, please also provide terminal output and/or
screenshots demonstrating your test/reproduction.
-->

Run docs locally and visit:
http://localhost:3002/router/reference/search-parameters/

## Preview

![CleanShot 2024-03-14 at 17 50
16@2x](https://github.com/expo/expo/assets/10234615/207ddeff-1df1-4ecb-934a-14dead6c7454)


# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).
@brentvatne brentvatne added the published Changes from the PR have been published to npm label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: fingerprint compatible bot: passed checks ExpoBot has nothing to complain about published Changes from the PR have been published to npm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants