ProtonMail / proton-account

Proton account settings
GNU General Public License v3.0
13 stars 4 forks source link

MainContainer.tsx: getAppFromPathnameSafe function possibly called with wrong value (lost "base name" prefix) #2

Open vladimiry opened 3 years ago

vladimiry commented 3 years ago

https://github.com/ProtonMail/proton-account/blob/d00e5966aa1fbbb95dab98ab83004180fa5a229b/src/app/content/MainContainer.tsx#L65

My understanding is that the arg should be changed location.pathname => window.location.pathname since currently it gets called with /mail/general arg instead of seems to be expected /account/mail/general and then gets converted to neral by https://github.com/ProtonMail/proton-shared/blob/03c8f95a7f9c90855ca2f39254f001842ce8d469/lib/authentication/pathnameHelper.ts#L26 ("/mail/general".slice("/account".length)) which ends up with unresolved app.

To recap, it works nicely if I change location.pathname => window.location.pathname since then the call looks like "/account/mail/general".slice("/account".length), so currently location.pathname use looses /account "base name".

PS There might be other places in the code base where similar issue takes place, I just highlighted the one case I've spotted.

vladimiry commented 3 years ago

Also notice that in some case it's already called with window.location.pathname arg https://github.com/search?q=org%3AProtonMail+getAppFromPathnameSafe&type=code