Skip to content
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

URL filling with nulls #785

Open
jrosindell opened this issue Apr 9, 2024 · 6 comments
Open

URL filling with nulls #785

jrosindell opened this issue Apr 9, 2024 · 6 comments

Comments

@jrosindell
Copy link
Member

Screenshot 2024-04-09 at 00 26 16

@davidebbo
Copy link
Contributor

@jrosindell I'm not seeing this behavior on Chrome, using the same tour at the same step. My URL looks like https://beta.onezoom.org/life/@biota=93302?otthome=%40_ozid%3D1&tour=%2Ftour%2Fdata.html%2Ffrogs%404#x783,y1066,w1.4031

Maybe there are other factors at play?

@lentinj
Copy link
Collaborator

lentinj commented Apr 15, 2024

@jrosindell @hyanwong did you figure out what needs to be done to replicate this? When does an extra "null/" get added? Could you copy-paste what the full URL looks like?

I'd guess it's something to do with 56cbc37, but I've not many ideas how off the top of my head.

@lentinj
Copy link
Collaborator

lentinj commented Apr 15, 2024

I could also believe it only happens if you start the tour in a particular way. Going to a URL like https://beta.onezoom.org/life/?tour=%2Ftour%2Fdata.html%2Ffrogs%401 would start the tour on page-load, and since the original URL doesn't have a pinpoint in, it'd be null.

It's a very neat explanation, but unfortunately the URL above seems to work fine.

@davidebbo
Copy link
Contributor

Right, I had tried a number of things, but could not reproduce this issue.

Not sure to what extent it's related, but I did notice that if you add random tokens to the URL path, they get preserved and the site otherwise works fine. e.g. https://beta.onezoom.org/life/random/other/tokens

@lentinj
Copy link
Collaborator

lentinj commented Apr 15, 2024

Yeah, that's how we're repeating the null/s. Everything before the final pathname part with the @ is treated as the base URL and preserved. Generally this is fine since we only modify the pinpoint at the end of the pathname.

A bodge would be to not record a URL if the pinpoint we're trying to record is null, but this would potentially break the share buttons.

lentinj added a commit that referenced this issue Apr 23, 2024
If a state doesn't have a pinpoint, we shouldn't be appending null to
it. Why this is the case I'm not sure, but this should at least stop
URLs filling with "null/".
@lentinj
Copy link
Collaborator

lentinj commented Apr 23, 2024

I still can't reproduce this (@hyanwong says that rapid fire "Next"ing can do it, but not here). However, the pull request should at least solve the repeated "null/"s.

I'm still not sure why there would be a state without a pinpoint mind, but the problem is somewhere around here:

// No OTT found to anchor the URL on, don't record
if (!current_state.pinpoint) return
// Not allowed to record when being served via file:
if (window.location.protocol === "file:") return;
// Don't bother recording if it's basically the same state
if (!force && current_view_near_previous_view(current_state)) return;
if (current_state.tour_setting) {
// Leave everything alone bar tour---parse existing state, splice tour state in.
const tour = current_state.tour_setting;
current_state = parse_state(window.location);
current_state.tour_setting = tour;
}

Note that (line 34) refuses to record a URL without a pinpoint, but when in a tour we ignore this state and craft our own based on the current page location. If this URL doesn't have a pinpoint, it'd get passed through regardless.

I don't think the solution is moving this check. We still want to record the current tourstop in the URL, so we can then refresh / share the current URL.

lentinj added a commit that referenced this issue Apr 23, 2024
navigation/state: deparse states missing a pinpoint #785
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants