-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
docs: #15988 follow-up: Use URL.parse to fix Version Switcher URL double slash issue #16014
base: main
Are you sure you want to change the base?
docs: #15988 follow-up: Use URL.parse to fix Version Switcher URL double slash issue #16014
Conversation
📖 Documentation deployed to pr-16014.preview.immich.app |
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.
This doesn't include any query params.
Maybe just to something like location.href.replace(location.origin, url) |
It doesn't handle the double slash, though. So I'll fix the issue in the |
@@ -49,7 +49,7 @@ export default function VersionSwitcher(): JSX.Element { | |||
mobile={windowSize === 'mobile'} | |||
items={versions.map(({ label, url }) => ({ | |||
label, | |||
to: url + location.pathname + location.hash, | |||
to: URL.parse(location.pathname + location.hash, url).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.
to: URL.parse(location.pathname + location.hash, url).href, | |
to: location.href.replace(location.origin, URL.parse(url.origin)), |
If I do this, it handles the double slash issue in case someone forgets about this and it ever happens again.
The URL constructor won't override the host, but we can just do that explicitly right? let url = new URL(location.href)
// URL { href: "https://github.com/immich-app/immich/pull/16014/files", origin: "https://github.com/", protocol: "https:", username: "", password: "", host: "github.com", hostname: "github.com", port: "", pathname: "/immich-app/immich/pull/16014/files", search: "" }
url.host = "immich.app"
url
// URL { href: "https://immich.app/immich-app/immich/pull/16014/files", origin: "https://immich.app/", protocol: "https:", username: "", password: "", host: "immich.app", hostname: "immich.app", port: "", pathname: "/immich-app/immich/pull/16014/files", search: "" } |
Hmm. I'll have to see how that goes. Edit: in dev builds it'll link to http://immich.app instead of https but that's probably fine since it'll probably redirect to https. |
It should retain the scheme of the original URL, which would be http in dev and https in prod. |
It breaks the dev instance though because of the port. https://url.spec.whatwg.org/#dom-url-host
|
2353b6e
to
b6d364d
Compare
b6d364d
to
09f81c5
Compare
Let me know what you think of the latest implementation. There doesn't seem to be any easy and obvious way to do this. |
Description
Uses
URL.parse(location.pathname + location.hash, url).href
instead ofurl + location.pathname + location.hash
I noticed the issue after PR #15988 was merged. Sorry about this 3rd PR. Maybe don't merge this until a day after all the comments are addressed so that we don't jinx it. 🤞🤞🤞
How Has This Been Tested?
npm run start
for docs.Screenshots (if appropriate)
Before:
![image](https://private-user-images.githubusercontent.com/30300649/411787821-6054bc1a-ce41-4bbe-815c-8fb69397863d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1NTA1NjgsIm5iZiI6MTczOTU1MDI2OCwicGF0aCI6Ii8zMDMwMDY0OS80MTE3ODc4MjEtNjA1NGJjMWEtY2U0MS00YmJlLTgxNWMtOGZiNjkzOTc4NjNkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDE2MjQyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWVmOTg5MGM0YWQ2MTFmNWEwODdhYmVjYzUxNWZjNDk0NWI3ZWMwY2E1N2E3YjM0YzgzNzU4N2EwN2RjMzE2ZTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.0mCA-otYhpmejNA9O8ihu6wfDeJp1bn5Lh0ISc_QmAE)
![image](https://private-user-images.githubusercontent.com/30300649/411788313-5ee8c9d6-1802-4b32-90ed-744c89f2815f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1NTA1NjgsIm5iZiI6MTczOTU1MDI2OCwicGF0aCI6Ii8zMDMwMDY0OS80MTE3ODgzMTMtNWVlOGM5ZDYtMTgwMi00YjMyLTkwZWQtNzQ0Yzg5ZjI4MTVmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDE2MjQyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE1ZDFlZmZlYjBhNzI3MTNlNmZjZDIyNTAxMjVhYzFmMzUzN2NkZTJjZTk1NTYzODJiMTIzZmJiOGNjMTM4M2ImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.kyAFjZf5dYM8tHL8FXMseqp0aoSVoBlYSz_2u59S9Mk)
After:
Checklist:
src/services
uses repositories implementations for database calls, filesystem operations, etc.src/repositories/
is pretty basic/simple and does not have any immich specific logic (that belongs insrc/services
)