Encode concept URIs in API calls with URLSearchParams (fix hash namespace issues)#1835
Encode concept URIs in API calls with URLSearchParams (fix hash namespace issues)#1835
Conversation
miguelvaara
left a comment
There was a problem hiding this comment.
Is there possibly a need to use URLSearchParams here in the same way as in the other corresponding cases?
|
@miguelvaara it is used there (one line below the one you linked) |
miguelvaara
left a comment
There was a problem hiding this comment.
Here the toString() function is used even though it is inside backticks (as I understand, the function should not be needed in that case).
Byt, for the sake of consistency, I think it would be good to either use the toString() function in all cases or leave it out everywhere. Regardless if it is actually needed or not, if it is used it would be good to use it in all cases of remove the one case with the function.
Here is the list of my quick glance:
Skosmos/resource/js/tab-alpha.js
Line 108 in dace6a8
Skosmos/resource/js/tab-changes.js
Line 57 in dace6a8
Skosmos/resource/js/tab-changes.js
Line 97 in dace6a8
Skosmos/resource/js/tab-groups.js
Line 97 in dace6a8
Skosmos/resource/js/tab-groups.js
Line 176 in dace6a8
Skosmos/resource/js/tab-hierarchy.js
Line 127 in dace6a8
Skosmos/resource/js/tab-hierarchy.js
Line 145 in dace6a8
Skosmos/resource/js/tab-hierarchy.js
Line 175 in dace6a8
Skosmos/resource/js/tab-hierarchy.js
Line 190 in dace6a8
miguelvaara
left a comment
There was a problem hiding this comment.
After many checks and a fairly extensive review, I can see that everything works as it should. In my view, it can be merged once the toString cases have been considered and the related fixes have been made (either removed everywhere or included everywhere)
Great job!
You right - my bad - sorry! |
|
|
I dropped the extra Note that since the search URL construction functionality is implemented in a different style (string concatenation, not string interpolation expressions), |
miguelvaara
left a comment
There was a problem hiding this comment.
Lines 457 to 461 in fb0e839
I think you should add the following:
skosmos:loadExternalResources "true";
After that tests pass and the issue disappears ...
| // check the first mapping property name | ||
| cy.get('.prop-mapping h2').eq(0).contains('Exactly matching concepts') | ||
| // check the first mapping property values | ||
| cy.get('.prop-mapping').eq(0).find('.prop-mapping-label').eq(0).contains('number sign') |
There was a problem hiding this comment.
cy.get('.prop-mapping').eq(0).find('.prop-mapping-label').eq(0).contains('number sign')
I cannot get it to pass. It fails with the following error because it expects the string ‘number sign’.
containsnumber sign / AssertionError
Timed out retrying after 4000ms: Expected to find content: 'number sign' within the element: <div.col-5.prop-mapping-label> but never did.
tests/cypress/template/concept-full-vs-partial.cy.js:164:71
cy.get('.prop-mapping').eq(0).find('.prop-mapping-label').eq(0).contains('number sign')
There was a problem hiding this comment.
skosmos:loadExternalResources defaults to true, so I don't think that can be the problem.
miguelvaara
left a comment
There was a problem hiding this comment.
The cause of the Wikidata label issue remains unknown. Nevertheless all tests now pass, so the merge can proceed.
Great work!



Reasons for creating this PR
It was reported in #1828 that concept mappings are not shown on concept pages where the concept URI contains a
#character. This turned out to be an URL encoding problem that affects many API calls and also breaks e.g. the hierarchy display.This PR changes the way REST API URLs are constructed to ensure that all arguments are properly URL encoded. String concatenation is replaced with URLSearchParams which handles encoding automatically.
The PR also includes a small test vocabulary which uses a hash-style namespace, and a Cypress test that verifies that mappings are loaded for these concepts (and indirectly also that the hierarchy is working).
Link to relevant issue(s), if any
Description of the changes in this PR
hashtest vocabularyKnown problems or uncertainties in this PR
I tried to dig through all our JS front-end code looking for problematic ways to construct URLs and replaced them all with URLSearchParams. I don't think I've missed any, but it's possible. I'm a bit unsure about
get-concept-url.js; it's quite ugly in its current form and doesn't use URLSearchParams, but it seems to me that it is still encoding URL parameters properly usingencodeURIComponentcalls, so I didn't touch it.Checklist
.sr-onlyclass, color contrast)