diff options
author | Linus Groh <mail@linusgroh.de> | 2021-04-03 15:15:31 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-03 16:34:34 +0200 |
commit | e02270c5cc1692761a60d7928e6d2adf740b27aa (patch) | |
tree | 0609b404ef85f3fdcea92a4136e6d4572db0ed14 /Userland/Libraries | |
parent | 000ef96613466427a4a84103778e6f0a423e2845 (diff) | |
download | serenity-e02270c5cc1692761a60d7928e6d2adf740b27aa.zip |
LibWeb: Make XMLHttpRequest.open() work with relative URLs
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp index 94a6bef629..72518bdb15 100644 --- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp +++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2021, Linus Groh <mail@linusgroh.de> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -124,6 +125,7 @@ DOM::ExceptionOr<void> XMLHttpRequest::set_request_header(const String& header, return {}; } +// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-open DOM::ExceptionOr<void> XMLHttpRequest::open(const String& method, const String& url) { // FIXME: Let settingsObject be thisโs relevant settings object. @@ -135,10 +137,9 @@ DOM::ExceptionOr<void> XMLHttpRequest::open(const String& method, const String& if (is_forbidden_method(method)) return DOM::SecurityError::create("Forbidden method, must not be 'CONNECT', 'TRACE', or 'TRACK'"); - String normalized_method = normalize_method(method); + auto normalized_method = normalize_method(method); - // FIXME: Pass in settingObject's API base URL and API URL character encoding. - URL parsed_url(url); + auto parsed_url = m_window->document().complete_url(url); if (!parsed_url.is_valid()) return DOM::SyntaxError::create("Invalid URL"); |