Worker URL obj parses double backslash diff from Chrome

(new URL(“http://bulk88sapp.herokuapp.com/https://api.foo.com/v3/sites/57c94b12-0965-42d3-9d3a-831d04c433fa/query/”)).pathname

In a CF Worker I get

“/https:/api.foo.com/v3/sites/57c94b12-0965-42d3-9d3a-831d04c433fa/query/”

In Chrome 83 console I get

“/https://api.foo.com/v3/sites/57c94b12-0965-42d3-9d3a-831d04c433fa/query/

Notice Chrome passes through the //, CF Worker V8 drops the // to a single / changing the path given to the actual API origin end point. Huh?Both the browser and a CFW are V8 JS Engine right?

I do see the warning at https://developers.cloudflare.com/workers/runtime-apis/web-standards but there needs to be documentation how CFW URL objects are different from W3C URL objects. Its a landmine if a CFW URL object retrieves a different file on origin than in a fake CFW/mockup on a devs machine with Node JS or Chrome console under a certain input.

Just add this to any CFW and look at the header

headers.set(“X-pathtest”,(new URL(“http://bulk88sapp.herokuapp.com/https://api.foo.com/v3/sites/57c94b12-0965-42d3-9d3a-831d04c433fa/query/”)).pathname)

only 1 / in pathname

+1, this seems like a legit bug. As a reduced example: http://example.com/hello//world parses incorrectly in a worker.

I believe that may be related to this:

Current fix/workaround for this would be to add a URL library/polyfill to your worker that parses your urls instead.