-
Notifications
You must be signed in to change notification settings - Fork 188
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
fix(url.ml): set_fragment need not any urlencode #1497
Conversation
We should probably check that |
Hi @hhugo, that's a good point, thanks! |
@erikmd, the round-tripping seems to work more often with your PR. In particular, it works with |
Not really it's difficult for me to say what is right here because:
Also Brr doesn't use Location objects which seems to be a different URI like structure (I conjecture kept for compat reasons). The API exposed by brr to interact with the browser location is to capture the location as an URL object and set the location from an URL object (and Brr does not try to mutate URL objects). In any case if you are interested in what happened in Brr the API is here and the recent discussion is there. |
Good! but out of curiosity, when do you think this does not "work"?
yes, almost: it returns what follows the
this is maybe another issue. See my initial comment. To sum up, more than 8 years ago, there was a bug in firefox about the location.getter. Hence the somewhat involved code before this PR that did not simply call the location.hash property. This bug is now solved, so I'd suggest we also simplify the getter code along the way. I will push another commit, @hhugo could you run the same tests? (maybe with Firefox + another Chromium-based browser) |
Hi @dbuenzli (disclaimer: I'm not expert in js_of_ocaml! I just give my thoughts based on standard specs)
IMO the API should faithfully map JavaScript properties to OCaml ones. And according to https://developer.mozilla.org/en-US/docs/Web/API/Location/hash:
According to examples from https://stackoverflow.com/questions/1703552/encoding-of-window-location-hash:
RFC 3986 says:
Indeed, there was a spurious urlencoding before this PR, which should not be there. |
You can test your self by building the toplevel
|
I don't really care about what it does. I'm just saying that the API docs should mention what is being done.
That's unrelated to the problem I mentioned (and so is checking stuff in the browser console).
That was not my point. The point is that this module has its own functions to perform url encoding. |
2f26252
to
60de61c
Compare
and directly use l##.hash; given Firefox' bug https://bugzilla.mozilla.org/show_bug.cgi?id=483304 is closed since 8+ years.
f2d3b2c
to
f7a1a29
Compare
CHANGES: ## Features/Changes * Compiler: global dead code elimination (Micah Cantor, ocsigen/js_of_ocaml#1503) * Compiler: change control-flow compilation strategy (ocsigen/js_of_ocaml#1496) * Compiler: loop no longer absorb the whole continuation * Compiler: Dead code elimination of unused references (ocsigen/js_of_ocaml#2076) * Compiler: reduce memory consumption (ocsigen/js_of_ocaml#1516) * Compiler: support for import and export construct in the js parser/printer * Lib: add download attribute to anchor element * Misc: switch CI to OCaml 5.1 * Misc: preliminary support for OCaml 5.2 * Misc: support for OCaml 5.1.1 ## Bug fixes * Runtime: fix Dom_html.onIE (ocsigen/js_of_ocaml#1493) * Runtime: add conversion functions + strict equality for compatibility with Wasm_of_ocaml (ocsigen/js_of_ocaml#1492) * Runtime: Dynlink should be able to find symbols in jsoo_runtime ocsigen/js_of_ocaml#1517 * Runtime: fix Unix.lstat, Unix.LargeFile.lstat (ocsigen/js_of_ocaml#1519) * Compiler: fix global flow analysis (ocsigen/js_of_ocaml#1494) * Compiler: fix js parser/printer wrt async functions (ocsigen/js_of_ocaml#1515) * Compiler: fix free variables pass wrt parameters' default value (ocsigen/js_of_ocaml#1521) * Compiler: fix free variables for classes * Compiler: fix internal invariant (continuation) * Compiler: fix variable renaming for let, const and classes * Lib: Url.Current.set_fragment need not any urlencode (ocsigen/js_of_ocaml#1497)
CHANGES: ## Features/Changes * Compiler: global dead code elimination (Micah Cantor, ocsigen/js_of_ocaml#1503) * Compiler: change control-flow compilation strategy (ocsigen/js_of_ocaml#1496) * Compiler: loop no longer absorb the whole continuation * Compiler: Dead code elimination of unused references (ocsigen/js_of_ocaml#2076) * Compiler: reduce memory consumption (ocsigen/js_of_ocaml#1516) * Compiler: support for import and export construct in the js parser/printer * Lib: add download attribute to anchor element * Misc: switch CI to OCaml 5.1 * Misc: preliminary support for OCaml 5.2 * Misc: support for OCaml 5.1.1 ## Bug fixes * Runtime: fix Dom_html.onIE (ocsigen/js_of_ocaml#1493) * Runtime: add conversion functions + strict equality for compatibility with Wasm_of_ocaml (ocsigen/js_of_ocaml#1492) * Runtime: Dynlink should be able to find symbols in jsoo_runtime ocsigen/js_of_ocaml#1517 * Runtime: fix Unix.lstat, Unix.LargeFile.lstat (ocsigen/js_of_ocaml#1519) * Compiler: fix global flow analysis (ocsigen/js_of_ocaml#1494) * Compiler: fix js parser/printer wrt async functions (ocsigen/js_of_ocaml#1515) * Compiler: fix free variables pass wrt parameters' default value (ocsigen/js_of_ocaml#1521) * Compiler: fix free variables for classes * Compiler: fix internal invariant (continuation) * Compiler: fix variable renaming for let, const and classes * Lib: Url.Current.set_fragment need not any urlencode (ocsigen/js_of_ocaml#1497)
CHANGES: ## Features/Changes * Compiler: global dead code elimination (Micah Cantor, ocsigen/js_of_ocaml#1503) * Compiler: change control-flow compilation strategy (ocsigen/js_of_ocaml#1496) * Compiler: loop no longer absorb the whole continuation * Compiler: Dead code elimination of unused references (ocsigen/js_of_ocaml#2076) * Compiler: reduce memory consumption (ocsigen/js_of_ocaml#1516) * Compiler: support for import and export construct in the js parser/printer * Lib: add download attribute to anchor element * Misc: switch CI to OCaml 5.1 * Misc: preliminary support for OCaml 5.2 * Misc: support for OCaml 5.1.1 ## Bug fixes * Runtime: fix Dom_html.onIE (ocsigen/js_of_ocaml#1493) * Runtime: add conversion functions + strict equality for compatibility with Wasm_of_ocaml (ocsigen/js_of_ocaml#1492) * Runtime: Dynlink should be able to find symbols in jsoo_runtime ocsigen/js_of_ocaml#1517 * Runtime: fix Unix.lstat, Unix.LargeFile.lstat (ocsigen/js_of_ocaml#1519) * Compiler: fix global flow analysis (ocsigen/js_of_ocaml#1494) * Compiler: fix js parser/printer wrt async functions (ocsigen/js_of_ocaml#1515) * Compiler: fix free variables pass wrt parameters' default value (ocsigen/js_of_ocaml#1521) * Compiler: fix free variables for classes * Compiler: fix internal invariant (continuation) * Compiler: fix variable renaming for let, const and classes * Lib: Url.Current.set_fragment need not any urlencode (ocsigen/js_of_ocaml#1497)
Dear js_of_ocaml maintainers,
This patch comes from an issue spotted in learn-ocaml (which heavily relies on js_of_ocaml), namely:
%3D
chars are rendered as=
ocaml-sf/learn-ocaml#539Note: I didn't recompile js_of_ocaml itself yet to test it, but I'm confident of the fix; to summarize what I understood:
http://localhost:8080/exercises/tp1/#tab=report
;Url.Current.set_fragment "tab=report"
to this aim;http://localhost:8080/exercises/tp1/#tab%3Dreport
, which is not that legible!;Dom_html.window##.location##.hash := Js.bytestring "tab=report"
solves the issue.document.location.hash
is documented at https://developer.mozilla.org/en-US/docs/Web/API/Location/hashHence this small patch; WDYT?