RangerMauve / hypercore-fetch

Implementation of Fetch that uses the Hyper SDK for loading p2p content
MIT License
36 stars 12 forks source link

Handle empty string pathname #71

Closed josephmturner closed 1 year ago

josephmturner commented 1 year ago
josephmturner commented 1 year ago

Resolves #64 .

alphapapa commented 1 year ago

@josephmturner @RangerMauve

Perhaps I'm being overly pedantic, but just a thought: rather than automatically adding/removing slashes to make received paths valid, would it be a good idea to return an appropriate HTTP error status code and a message like, "Invalid path: paths must begin with a / and not end with one"? Generally I advocate for Postel's Law, but in this case, insisting on "correctness" might help prevent clients from making mistakes and having bugs on their end.

RangerMauve commented 1 year ago

@alphapapa I think in this case all paths should start with a / if they're parsed by the URL object, I'm not 100% sure which edge cases they would be omitted in. 🤔

I'm also into throwing an error if we get a weird URL.

josephmturner commented 1 year ago

I'm also into throwing an error if we get a weird URL.

+1