srctree

Robin Linden parent 92f16d2c 4880144b
browser/engine: Nuke workarounds for uris with empty paths

They're no longer needed now as we do some normalization on the uripaths.

inlinesplit
browser/engine.cpp added: 4, removed: 15, total 0
@@ -35,10 +35,6 @@ protocol::Error Engine::navigate(uri::Uri uri) {
return status_code == 301 || status_code == 302 || status_code == 307 || status_code == 308;
};
 
if (uri.path.empty()) {
uri.path = "/";
}
 
if (uri.scheme.empty() && uri.authority.host.empty() && uri.path.starts_with('/')) {
spdlog::info("Handling origin-relative URL {}", uri.uri);
uri = uri::Uri::parse(fmt::format("{}://{}{}", uri_.scheme, uri_.authority.host, uri.uri)).value();
@@ -53,9 +49,6 @@ protocol::Error Engine::navigate(uri::Uri uri) {
uri_.uri,
response_.headers.get("Location").value());
uri_ = *uri::Uri::parse(std::string(response_.headers.get("Location").value()));
if (uri_.path.empty()) {
uri_.path = "/";
}
response_ = protocol_handler_->handle(uri_);
}
 
 
browser/engine_test.cpp added: 4, removed: 15, total 0
@@ -79,12 +79,8 @@ int main() {
etest::test("origin-relative uri", [] {
browser::Engine e{std::make_unique<FakeProtocolHandler>(protocol::Response{.err = protocol::Error::Ok})};
 
// TOOD(robinlinden)
// `/` being included as the path here is important as the uri-parser
// currently doesn't do normalization, and the browser engine patches
// the uri to work when the path is empty.
e.navigate(*uri::Uri::parse("hax://example.com/"));
expect_eq(e.uri(), *uri::Uri::parse("hax://example.com/"));
e.navigate(*uri::Uri::parse("hax://example.com"));
expect_eq(e.uri(), *uri::Uri::parse("hax://example.com"));
 
e.navigate(*uri::Uri::parse("/test"));
expect_eq(e.uri(), *uri::Uri::parse("hax://example.com/test"));