-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(web): handle trailing slash in external domain #6253
Conversation
Deploying with
|
Latest commit: |
2ae48df
|
Status: | ✅ Deploy successful! |
Preview URL: | https://4c4cda51.immich.pages.dev |
Branch Preview URL: | https://fix-sanitize-external-domain.immich.pages.dev |
const url = externalDomain || window.location.origin; | ||
return `${url + url.endsWith('/') ? '' : '/'}share/${key}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use a URL
constructor instead? I believe this should work (untested):
const url = externalDomain || window.location.origin; | |
return `${url + url.endsWith('/') ? '' : '/'}share/${key}`; | |
const base = externalDomain || window.location.origin; | |
return new URL(`/share/${key}`, base).href; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's very well possible. I only did a quick google search (less than 1 minute lol) and people were like "yea, regex" lol
I'll test it real quick
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently this doesn't work if your domain has a path as well (so immich.app/public/)
. Not sure if that's common though...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point, though at the moment it's not possible to run Immich under a path anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it not possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We haven't tested with it and I think there are some things that don't work with it like goto(/photos)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that there are absolute paths but I was thinking you could have proxy rewrite rules for that stuff. Or well, at that point, you could also redirect /share to /public/share, nvm lol
I'm wondering if it would be better to just validate this in the config, rather than have to correct for it later |
I was thinking about that as well. Basically you have three options:
IMO 2) is kinda ugly because then you save something and on reload there is something else. That's confusing. And 1) could be annoying I think because technically it's not wrong and I personally hate it when I get errors that shouldn't be errors and only happen because the software is too stupid to handle those lmao |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I went through this same mental exercise and I think this solution works well enough. |
Addresses #6146 (comment)