Whether pathname includes base depends on whether there is an anchor (#foo)
evanbattaglia opened this issue · comments
I apologize if I missed an existing issue for this, or if this is expected behavior, but it seems surprising to me. #575 is similar but this is specifically around pathname and base URL. Assuming hashbang
is false, if there is no hash symbol (anchor) in the document URL, the pathname is based on path
so includes the base URL. In Context():
Line 1090 in 4f99916
However, if there is a hash symbol (anchor), pathname depends on this.path
, which does not have the base URL.
Line 1098 in 4f99916
I came across while tracking a bug in our code. Here is a gist which shows the behavior in isolation.
https://gist.github.com/evanbattaglia/2b76bf11fe8a18ac4dcef14f2138a2cc
URL: /index
-> pathname /basic/
URL: /index#whoop
-> pathname /
URL: /basic/about
-> pathname /basic/about
URL: /basic/about#whoop
-> pathname /about
The documentation states pathname is The pathname void of query string "/login".
, which implies it should not have the base URL (/admin
in the documentation).