vike icon indicating copy to clipboard operation
vike copied to clipboard

Offer `href` in `urlParsed`

Open openscript opened this issue 1 year ago • 2 comments

Description

In my opinion urlParsed should contain a href. My reasoning is URL also contains that and the DX would improve.

For example https://vike.dev/i18n describes:

const urlWithoutLocale = `${origin || ''}${pathnameWithoutLocale}${searchOriginal || ''}${hashOriginal || ''}`

This would become

const urlWithoutLocale = url.href.replace(url.pathname, url.pathnameWithoutLocale)

openscript avatar May 02 '24 05:05 openscript

Agreed :+1: Would you be up for PR for this as well? AFAICT this one should actually be fairly easy (easier than the other one).

(On a tangent, I was thinking it would also be nice to offer/document an easier way to manipulate the URL. The issue with url.href.replace(url.pathname, url.pathnameWithoutLocale) is that it may fail for example for a url.pathname that is /en and a URL /en?movies/endeavour which would become /?movies/deavour.)

brillout avatar May 02 '24 07:05 brillout

Would you be up for PR for this as well?

Sure, I'll give it a try. :)

openscript avatar May 02 '24 07:05 openscript

Done & released, see modifyUrl() at https://vike.dev/i18n.

Btw. would your company be up for sponsoring (#1350)? It makes a foundamental difference!

brillout avatar Jul 19 '24 12:07 brillout

Thank you very much for implementing the feature!

Btw. would your company be up for sponsoring (https://github.com/vikejs/vike/issues/1350)? It makes a foundamental difference!

Absolutely. When we earn the first time money with a project where Vike is involved, we will do that.

openscript avatar Jul 19 '24 14:07 openscript

Absolutely. When we earn the first time money with a project where Vike is involved, we will do that.

Thank you, that's much appreciated :green_heart:

brillout avatar Jul 22 '24 07:07 brillout