WICG/navigation-api

Extend NavigationInterceptOptions - optional url field

uasan opened this issue · 3 comments

uasan commented

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?

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

uasan commented

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

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