Comments (6)
You are trying to parse an URL with an authority (scheme://authority), an authority must include a non-empty host.
from rust-url.
Oh wait, no, I stand corrected:
reg-name = *( unreserved / pct-encoded / sub-delims )
from rust-url.
FWIW
new URL("postgres://postgres@/var/run/postgresql").username === ""
is true
for both Firefox and Chrome
from rust-url.
@alexcrichton Not sure why I didn’t respond to this a year ago, sorry. To use "non-standard" schemes like postgres:
you probably want a custom "scheme type mapper" https://servo.github.io/rust-url/url/struct.UrlParser.html#method.scheme_type_mapper .
@nox Where is that quote from? This crates implements http://url.spec.whatwg.org/ which sometimes diverges from the various relevant IETF RFCs.
@frewsxcv The Rust API of this crate and its behavior is not necessarily the same as https://url.spec.whatwg.org/#api (which is designed for JavaScript and web compat) as long as it enables Servo to implement it on top.
from rust-url.
The Rust API of this crate and its behavior is not necessarily the same as https://url.spec.whatwg.org/#api (which is designed for JavaScript and web compat) as long as it enables Servo to implement it on top.
I thought about that possibility, but wasn't sure. Thanks for clarifying 👍
from rust-url.
This passes in 1.0:
let mut url = Url::from_file_path(filename).unwrap();
url.set_scheme("postgres").unwrap();
url.set_host(Some("")).unwrap();
url.set_username("me").unwrap();
assert_eq!(url.as_str(), "postgres://me@/run/pg.sock");
The idea is that you can’t have a username without a host, but an empty host is not the same as no host. It’s not clear whether empty hosts make sense though, so I don’t know if it’s a good idea to rely on them. (The spec might change to forbid them and I’ll update rust-url to follow.) set_host(Some("localhost"))
would be safe, though.
from rust-url.
Related Issues (20)
- idna::punycode::encode_str() wrong conversion ? HOT 2
- Add parameter spaceAsPlus to ByteSerialize
- Incorrect parsing of Windows drive letter quirk
- Invalid IPv4 but parsing success HOT 1
- URL http:www.google.com is passed as validated HOT 1
- Host should implement deserialize to parse strings
- JOIN functionality not working HOT 4
- URL validity change between 2.2 and 2.3. HOT 2
- Documentation for IDNA configuration options should explain use cases
- Feature request: add parser boolean option to leave relative paths in the URL.
- Neither punycode::encode_str nor Config::...::to_ascii return expected results for single Unicode char and "EXAMPLE" HOT 3
- `Url::from_file_path()` incorrect handling of backslash on linux
- `=` is not being escaped as query value HOT 2
- [DataUrl] Unable to parse application/json;utf8 containing # HOT 1
- Feature request: provide separate struct for URL which is can-be-base
- Error: 🚫 Building project failed: error[E0583]: file not found for module `origin`serde, interproc... HOT 2
- Poping a path segment removes slash separator HOT 2
- No hostname format validation in URL HOT 5
- The input urls generated by the fuzzer can be problematic as it causes very long parse times
- Incorrect error when url contains number sign HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-url.