Skip to content

Conversation

@jampukka
Copy link
Collaborator

@jampukka jampukka commented Oct 23, 2025

Issue is that window.location.href already contains the window.location.search causing duplicated search part

Simplify JSON link construction in all files to just append (?|&)f=json to window.location.href based on search being empty (then ?) or not (then &). This should additionally fix JSON links when using any other query parameters (?filter= or ?api-key=<key> for example).
Not ideal still, if current search already contains value for query param f then this won't work, but that basically requires the user to manually enter ?f=html, which shouldn't really happen.

Should fix #160

@nls-jajuko
Copy link
Collaborator

nls-jajuko commented Oct 25, 2025

I've used URL search parameters to modify location in hakunapi-html-npm-openlayers

f.ex.

const params = (new URL(document.location)).searchParams;
	  params.set('crs',selectedCrsURI);
	  document.location.search = params.toString(); 	 

hakunapi-html-npm-openlayers has some other packaging and distribution build tree shaking issues though.
It's a bit heavy to load at the moment.

@jampukka
Copy link
Collaborator Author

That's a lot better, I'll change all of these to use that pattern.

@jampukka
Copy link
Collaborator Author

This seems to work with everything I throw at it

@nls-jajuko nls-jajuko added this to the 1.6.1 milestone Oct 28, 2025
@teezip teezip modified the milestones: 1.6.1, 1.7.0 Dec 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTML /items page JSON links are broken for non-default CRS

4 participants