-
Couldn't load subscription status.
- Fork 11
feat: extract callbacks to library #1280
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
Changes from all commits
83dda5a
ba94cd9
c90f43c
122d302
df69093
bc82ae5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,42 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <script setup lang="ts"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const parseRedirectTarget = (target: string | null) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (target && target !== '/') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // parse target and ensure it is a bare path with no query parameters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(target); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return '/'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return '/'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const getRedirectUrl = () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const search = new URLSearchParams(window.location.search); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const targetRoute = parseRedirectTarget(search.get('target')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (search.has('data') && (search.size === 1 || search.size === 2)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return `${window.location.origin}${targetRoute}?data=${encodeURIComponent(search.get('data')!)}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return `${window.location.origin}${targetRoute}`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onMounted(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setTimeout(() => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like it will immediately redirect without ever showing the text. What's the desired ux for this? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const textElement = document.getElementById('text'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (textElement) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| textElement.style.display = 'block'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, 750); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| window.location.href = getRedirectUrl(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+20
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing import for The <script setup lang="ts">
+import { onMounted } from 'vue';
const parseRedirectTarget = (target: string | null) => {📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </script> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <template> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id="text" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| style="text-align: center; margin-top: calc(100vh - 75%); display: none; font-family: sans-serif" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <h1>Redirecting...</h1> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <h2><a :href="getRedirectUrl()">Click here if you are not redirected automatically</a></h2> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </template> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This file was deleted.
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.
The
parseRedirectTargetfunction doesn't perform any actual validationThis function has a comment indicating it should parse and ensure the target is a bare path without query parameters, but it actually just logs the target and always returns '/'. This makes the conditional logic ineffective as the function will always return the home route regardless of input.
const parseRedirectTarget = (target: string | null) => { if (target && target !== '/') { // parse target and ensure it is a bare path with no query parameters - console.log(target); - return '/'; + // Remove query parameters if present + const parsedUrl = new URL(target, window.location.origin); + return parsedUrl.pathname; } return '/'; };📝 Committable suggestion