mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:07:35 +00:00
LibWeb: Make XMLHttpRequest.open() work with relative URLs
This commit is contained in:
parent
000ef96613
commit
e02270c5cc
1 changed files with 4 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||||
|
* Copyright (c) 2021, Linus Groh <mail@linusgroh.de>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* 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 {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://xhr.spec.whatwg.org/#dom-xmlhttprequest-open
|
||||||
DOM::ExceptionOr<void> XMLHttpRequest::open(const String& method, const String& url)
|
DOM::ExceptionOr<void> XMLHttpRequest::open(const String& method, const String& url)
|
||||||
{
|
{
|
||||||
// FIXME: Let settingsObject be this’s relevant settings object.
|
// 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))
|
if (is_forbidden_method(method))
|
||||||
return DOM::SecurityError::create("Forbidden method, must not be 'CONNECT', 'TRACE', or 'TRACK'");
|
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.
|
auto parsed_url = m_window->document().complete_url(url);
|
||||||
URL parsed_url(url);
|
|
||||||
if (!parsed_url.is_valid())
|
if (!parsed_url.is_valid())
|
||||||
return DOM::SyntaxError::create("Invalid URL");
|
return DOM::SyntaxError::create("Invalid URL");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue