Skip to content

Commit

Permalink
Remove Unicode serialization of an origin: url::origin_unicode()
Browse files Browse the repository at this point in the history
  • Loading branch information
rmisev committed May 9, 2019
1 parent 3aca431 commit 65478ef
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions src/url.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ class url {

// ASCII serialized origin
std::string origin() const;
// Unicode serialized origin in utf-8
std::string origin_unicode() const;

str_view_type protocol() const;

Expand Down Expand Up @@ -688,36 +686,6 @@ inline std::string url::origin() const {
return "null"; // opaque origin
}

// Unicode serialization of an origin
// https://html.spec.whatwg.org/multipage/browsers.html#unicode-serialisation-of-an-origin
inline std::string url::origin_unicode() const {
if (is_special_scheme()) {
if (is_file_scheme())
return "null"; // opaque origin
// "scheme://"
std::string str_origin(norm_url_, 0, part_end_[SCHEME_SEP]);

// if host is a domain, then apply domain to Unicode
auto hostv = get_part_view(HOST);
if (host_type() == HostType::Domain) {
simple_buffer<char> buff;
IDNToUnicode(hostv.data(), hostv.length(), buff);
str_origin.append(buff.begin(), buff.end());
} else {
str_origin.append(hostv.data(), hostv.length());
}

if (!is_null(PORT))
str_origin.append(norm_url_.data() + part_end_[HOST], norm_url_.data() + part_end_[PORT]);
return str_origin;
} else if (get_part_view(SCHEME).equal({ "blob", 4 })) {
url u;
if (u.parse(get_part_view(PATH), nullptr) == url_result::Ok)
return u.origin_unicode();
}
return "null"; // opaque origin
}

inline url::str_view_type url::protocol() const {
// "scheme:"
return str_view_type(norm_url_.data(), part_end_[SCHEME] ? part_end_[SCHEME] + 1 : 0);
Expand Down

0 comments on commit 65478ef

Please sign in to comment.