Skip to content

Extend NavigationInterceptOptions - optional url field #249

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

Closed
uasan opened this issue Oct 6, 2022 · 3 comments
Closed

Extend NavigationInterceptOptions - optional url field #249

uasan opened this issue Oct 6, 2022 · 3 comments

Comments

@uasan
Copy link

uasan commented Oct 6, 2022

There are many cases (trailing slashes, the most common case) where it is necessary to change the url in the navigation event handler method without canceling the current event and not create new event.

For example, we have canonical urls, if the user go to a non-canonical alias, we need to make the transition, but change this url to canonical, without canceling the current event, so that the caller does not receive a cancellation exception.

I propose extends NavigationInterceptOptions add optional property url - correct string value within the current location.origin.

navigation.addEventListener('navigate', e => {
  //...
  e.intercept({
    url: isNonCanonical(e.destination.url) ? getCanonical(e.destination.url) : undefined,
    async handler() {
      // ....
    }
  });
});

What do you think?

@uasan uasan changed the title Allow set destination.url, before called intercept Extend NavigationInterceptOptions - optional url field Oct 6, 2022
@tbondwilkinson
Copy link
Contributor

Is this the same request as a client side redirect? #124

@uasan
Copy link
Author

uasan commented Oct 6, 2022

Thanks, I didn’t read it.
Yes, these are solutions to the same problems.
I briefly suggested a simple solution here using a real example

@domenic
Copy link
Collaborator

domenic commented Oct 7, 2022

Yeah, let's roll this into #124. Thanks for showing up to let us know that feature is important to you!

@domenic domenic closed this as completed Oct 7, 2022
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

No branches or pull requests

3 participants