#2642 JS: Uri.query() bug

SlimerDude Wed 27 Sep

Uri.query() in the JS runtime returns the wrong value.

uri := Uri.decode("/result.html?id=69")

uri.toStr        // --> /result.html?id=69
uri.queryStr     // --> id=69
uri.query["id"]  // --> null,69  --> OOPS! Expected just "69"

I noticed this when when trying to extract data from a window URL via dom::Win.cur.uri().

andy Wed 27 Sep

I don't think there is anything wrong with Uri:

var uri = fan.sys.Uri.decode("/result.html?id=69")

uri.toStr()
"/result.html?id=69"

uri.queryStr()
"id=69"

uri.query().get("id")
"69"

So if there is an issue its probably around encoding/decoding what we are receiving from Window.location -- can you poke around WinPeer.js and see if anything turns up?

SlimerDude Wed 27 Sep

its probably around encoding/decoding what we are receiving from Window.location

Naa, that's the first thing I checked before posting, and it's fine.

I don't know what to say, other than here's a screenshot of my Chrome console that clearly shows null,69 even when using Javascript:

Uri decode in Chrome

The example.html is just:

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="/pod/sys/sys.js"></script>
</head>
<body></body>
</html>

As for my Chrome version, it's Windows and:

Google Chrome is up to date
Version 61.0.3163.100 (Official Build) (64-bit)

I get the same error on Waterfox / Firefox v 54.0.1 (64-bit).

Uri decode in Waterfox

I'm using some version of Fantom 1.0.69, but I've not re-compiled from tip recently - that said, I don't recall any recent JS Uri work.

I don't have a Fantom dev environment as it takes forever to setup, but if you want to email over a new sys pod, I can re-try it with that?

andy Wed 27 Sep

I'm using some version of Fantom 1.0.69, but I've not re-compiled from tip recently - that said, I don't recall any recent JS Uri work.

https://bitbucket.org/fantom/fan-1.0/commits/501e3f349a496394dccde79cc0d6709dafacfa8d

:)

SlimerDude Thu 28 Sep

Groan, thanks for that!

Though I'm disappointed I've wasted so much time on something that was fixed 6 months ago. :(

Login or Signup to reply.