#url serializer refresh

1 messages · Page 1 of 1 (latest)

pseudo barn
#

(1) without serializer

  // providers: [{ provide: UrlSerializer, useClass: CustomUrlSerializer }],

i have this url format : .../two(bar:beta)

(2) with serializer (to remove parentheses)

  providers: [{ provide: UrlSerializer, useClass: CustomUrlSerializer }],

i have this url format : ../two/bar:beta

(2) that's what I want
** but there is a problem refreshing the page
../two/bar:beta
i refresh page
"/two/bar:beta" disappear
I'm on the root url, but I don't want it to keep the path

https://stackblitz.com/edit/angular-ivy-2nhskh?file=src%2Fapp%2Fcustom-url-serializer.ts,src%2Fapp%2Fapp.module.ts

velvet fjord
#

Currently your URL serializer is one-way. On serialization it removes the parentheses. But on parsing it needs to correctly identify the router outlets again, currently it doesn't do this.

#

Or, worded differently (in pseudocode):
foo == yourSerializer.parse(yourSerializer.serialize(foo)) must always be true.

pseudo barn
velvet fjord
#

Unfortunately by removing the parentheses, you are removing information from the URL which will make it harder to reconstruct. You'll have to decide on a convention ("every path part with a colon in it designates an outlet" or something similar) and then reconstruct the URL tree based on that.

pseudo barn
velvet fjord
#

I don't know either, because by removing the parantheses you are removing information from the URL which is vital for reconstructing it.