Skip to content

Commit d03dd49

Browse files
committed
fix: handle new origin changes in standard
1 parent e45dd13 commit d03dd49

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/url-getters.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "ada.h"
66
#include "ada/implementation.h"
77
#include "ada/helpers.h"
8+
#include "ada/scheme.h"
89

910
#include <algorithm>
1011
#include <string>
@@ -22,7 +23,10 @@ namespace ada {
2223
if (non_special_scheme == "blob") {
2324
if (!path.empty()) {
2425
auto result = ada::parse<ada::url>(path);
25-
if (result && result->is_special()) {
26+
if (result &&
27+
(result->type == scheme::HTTP || result->type == scheme::HTTPS)) {
28+
// If pathURL’s scheme is not "http" and not "https", then return a
29+
// new opaque origin.
2630
return ada::helpers::concat(result->get_protocol(), "//",
2731
result->get_host());
2832
}

src/url_aggregator.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,9 @@ bool url_aggregator::set_hostname(const std::string_view input) {
634634
std::string_view path = get_pathname();
635635
if (!path.empty()) {
636636
auto out = ada::parse<ada::url_aggregator>(path);
637-
if (out && out->is_special()) {
637+
if (out && (out->type == scheme::HTTP || out->type == scheme::HTTPS)) {
638+
// If pathURL’s scheme is not "http" and not "https", then return a
639+
// new opaque origin.
638640
return helpers::concat(out->get_protocol(), "//", out->get_host());
639641
}
640642
}

0 commit comments

Comments
 (0)