fune/servo/components/script/dom/urlhelper.rs
Simon Sapin 2a5f4c7376 servo: Merge #3487 - Upgrade Rust and enable style crate rustdoc (from servo:rustup-20140923); r=Ms2ger
The biggest language change is that enum variants now also reserve (for future use) a name in the type namespace, which must not collide with other types. Some things were renamed, and others qualified as `module::name`.

Source-Repo: https://github.com/servo/servo
Source-Revision: 7409685589c550ee7a9f94182f511acddab4c6fd
2014-09-29 10:45:27 -06:00

30 lines
862 B
Rust

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use servo_util::str::DOMString;
use url::Url;
pub struct UrlHelper;
impl UrlHelper {
pub fn Href(url: &Url) -> DOMString {
url.serialize()
}
pub fn Search(url: &Url) -> DOMString {
match url.query {
None => "".to_string(),
Some(ref query) if query.as_slice() == "" => "".to_string(),
Some(ref query) => format!("?{}", query)
}
}
pub fn Hash(url: &Url) -> DOMString {
match url.fragment {
None => "".to_string(),
Some(ref hash) if hash.as_slice() == "" => "".to_string(),
Some(ref hash) => format!("#{}", hash)
}
}
}