Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(scroll): leading // no longer crashes scrollBehavior init#3679

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
snoozbuster wants to merge1 commit intovuejs:dev
base:dev
Choose a base branch
Loading
fromsnoozbuster:dev

Conversation

snoozbuster
Copy link

Fixes#2593.

@snoozbustersnoozbuster changed the titlefix(scroll): leading // no longer crashes router initfix(scroll): leading // no longer crashes scrollBehavior initDec 15, 2021
@@ -138,6 +139,15 @@ module.exports = {
'scroll to anchor on load'
)

// #2593 no crash on malformed URL
.url('http://localhost:8080//scroll-behavior')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I saw your comment on the issue but entering through this URL is not correct because the/scroll-behavior/ section is the base URL. Meaning that in a real scenario, the server should not serve this URL. It just happens to serve with the dev server because it's a simple fallback server that doesn't care about the base but in a real-world scenario, the fallback happensafter/scroll-behavior/, the base URL. The server should actually 404 on this URL

Copy link
Author

@snoozbustersnoozbusterDec 15, 2021
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

what if the base URL is/? our production setup is to serve our vue app on the root of the domain. I see what you're saying when the app base URL is something other than the root, but in that case shouldn't this still work?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

but then you are looking for/scroll-behavior// (or// if base is/)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

right - in this case the base is//. thescroll-behavior part of this URL doesn't really matter to the reproduction or the fix, IIRC there just needs to be something rendered in order to assert on it being there (since the crash generally causes nothing to be rendered at all).

@@ -22,7 +23,8 @@ export function setupScroll () {
// preserve existing history state as it could be overriden by the user
const stateCopy = extend({}, window.history.state)
stateCopy.key = getStateKey()
window.history.replaceState(stateCopy, '', absolutePath)
// Fix for #2593 clean path to avoid crashing entire app on paths with leading double-slash (http://example.com//foo/bar)
window.history.replaceState(stateCopy, '', cleanPath(absolutePath))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Maybe theabsolutePath should not remove the protocol and path in line 22 but we need to make sure this change works well withfile:// protocol as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think that would be ideal, but I don't 100% understand what this code is written to accomplish. there aren't any UTs on this method and I wasn't able to get the e2e tests running locally due to a chromedriver/chrome version mismatch I couldn't resolve, so I kinda need to be sure of what I'm doing in order to prevent needing to push random changes to run circleci builds

@snoozbuster
Copy link
Author

hey@posva - how do you want me to proceed on this? is there some issue with this fix as written, and if so can you clarify so that I can fix it?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@posvaposvaAwaiting requested review from posva

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

replaceState Error when path starts with // and scrollBehavior is set
2 participants
@snoozbuster@posva

[8]ページ先頭

©2009-2025 Movatter.jp