Skip to content

Repository files navigation

rust-url

Rust implementation of the URL Standard.

See Rust bug #10707.

This depends on rust-encoding.

API

pubstructURL{scheme: ~str,scheme_data:SchemeData,query:Option<~str>,// See form_urlencoded::parse_str() to get name/value pairs.fragment:Option<~str>,}pubenumSchemeData{RelativeSchemeData(SchemeRelativeURL),OtherSchemeData(~str),// data: URLs, mailto: URLs, etc.}pubstructSchemeRelativeURL{userinfo:Option<UserInfo>,host:Host,port: ~str,path: ~[~str],}pubstructUserInfo{username: ~str,password:Option<~str>,}pubenumHost{Domain(~[~str]),// Can only be empty in the file schemeIPv6(IPv6Address)}pubstructIPv6Address{pieces:[u16, ..8]}pubtypeParseResult<T> = Result<T,&'staticstr>;implURL{// base_url is used to resolve relative URLs.// Relative URLs without a base return an error.pubfnparse(input:&str,base_url:Option<&URL>) -> ParseResult<URL>pubfnserialize(&self) -> ~strpubfn serialize_no_fragment(&self) -> ~str}implHost{pubfnparse(input:&str) -> ParseResult<Host>pubfnserialize(&self) -> ~str}implIPv6Address{pubfnparse(input:&str) -> ParseResult<IPv6Address>pubfnserialize(&self) -> ~str}/// application/x-www-form-urlencoded/// Converts between a query string and name/value pairs.pubmod form_urlencoded {pubfnparse_str(input:&str) -> ~[(~str, ~str)]pubfnparse_bytes(input:&[u8],encoding_override:Option<encoding::EncodingRef>,use_charset:bool,isindex:bool) -> Option<~[(~str, ~str)]>pubfnserialize(pairs: ~[(~str, ~str)],encoding_override:Option<encoding::EncodingRef>) -> ~str}

To do

Not necessarily in the given order:

  • Add proper documentation
  • Add data: URL parsing.
  • Port rust-http and Servo.
  • Add IDNA support. Non-ASCII domains are a parse error for now. Punycode is done, Nameprep is the other big part.
  • Add lots of tests. Contribute them to web-platform-tests.
  • Report know/suspected spec bugs and test suite bugs.
  • Refactor to reduce code duplication.
  • Consider switching the spec from a state machine to functional style, like this code.

About

URL parser for Rust

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages