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)
- [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
- URI and IRI support? HOT 1
- `form_urlencoded::ByteSerialize` does NOT conform to the URL standard HOT 1
- Why is IP convert to Domain HOT 3
- perf: Use `NonZeroU16` for port numbers
- Url with quote after schema is getting parsed as valid. HOT 13
- v2.5.1 breaking crates.io CI HOT 1
- MSRV bump 1.67 in v2.5.1 HOT 23
- idna `to_unicode()` API has degraded in 1.0 HOT 10
- Massive regression in compile times HOT 20
- data-url: Fuzzed data URL causes high memory usage
- Upgrade to 2.5.1 breaks compilation on Windows HOT 3
- Upgrading url downgrades idna HOT 1
- URL 2.5.x 4+MB in size after optimised build. HOT 5
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.