can this be further simplified
i have run into an issue in an astro template and am gonna make a pr with the fix. but the current solution feels hacky
can this be simplified somehow? should i just make a pr and let the maintainers review it?
58 Replies
Excuse me but why are you first removing the slash and then adding it back
cuz u only add it back if href==="/"
you could check b4 removing w/ turnary ig
okay so Astro.url.pathname returns "/" for home and "/blog/" for blog and href is only "/blog" so they don't match and it doesn't become acting
so i have to remove the trailing slash
but then in home "/" becomes ""
so i have to add it back just for home
I’d test with RegEx if the pathname only contains slash and if not is just trimEnd
should you really put complex regex in a template tho?
astro is really aimed at beginners i think we should keep it as simple as possible
Gonna think, brb I’m a minute
nexxel is this the use you are looking for?
or
tho ^ and $ might need to be replaced with \A and \z
lemme try both of these
this doesn't seem to work :(
i didnt try it myself lol
oh, cuz i didnt reassign after replace maybe
coz astro.url.pathname is always truthy
""
|| compares the length of strings.
isnt pathname for home is '/' ?
wasnt going to assume