Skip to content

Incoming requests: bad parsed query value #29

@benjamin-thomas

Description

@benjamin-thomas
{
    "type": "application",
    "platform": "node",
    "source-directories": [
        "src"
    ],
    "gren-version": "0.5.3",
    "dependencies": {
        "direct": {
            "gren-lang/core": "6.0.1",
            "gren-lang/node": "5.0.3",
            "gren-lang/url": "5.0.0"
        },
        "indirect": {}
    }
}


When a request comes in, the parsed URL should look like this:

-- Url.fromString "http://localhost:4000/blog/123?q=0&r=1#tag"
Just { fragment = Just "tag", host = "localhost", path = "/blog/123", port_ = Just 4000, protocol = Http, query = Just "q=0&r=1" }

However, the query attribute comes with an extra ?, making the related query parser fail.

{ fragment = Nothing, host = "localhost", path = "/blog/123", port_ = Just 4000, protocol = Http, query = Just "?q=0&r=1" }

The problem seems to be here:

__$urlQuery: url.search,

In node, an extra char appear in the parsed output of query and hash:

> new URL("http://localhost:8080/blog/1?a=123&b=456#tag")
URL {
  href: 'http://localhost:8080/blog/1?a=123&b=456#tag',
  origin: 'http://localhost:8080',
  protocol: 'http:',
  username: '',
  password: '',
  host: 'localhost:8080',
  hostname: 'localhost',
  port: '8080',
  pathname: '/blog/1',
  search: '?a=123&b=456',
  searchParams: URLSearchParams { 'a' => '123', 'b' => '456' },
  hash: '#tag'
}

I wanted to try a change locally, by pointing my gren-lang/node to a localfile, but couldn't compile. Is it possible to play with kernel code locally to experiment?

I think we should run url.search.slice(1) and url.hash.slice(1) to conform to the historical parse result.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions