瀏覽代碼

LibWeb/Fetch: Tweak wording in some spec comments

This is a change in the Fetch spec.

See: https://github.com/whatwg/fetch/commit/223ca89
Linus Groh 2 年之前
父節點
當前提交
2f1bda3347

+ 4 - 4
Userland/Libraries/LibWeb/Fetch/Headers.cpp

@@ -282,20 +282,20 @@ WebIDL::ExceptionOr<void> Headers::fill(HeadersInit const& object)
 {
     // To fill a Headers object headers with a given object object, run these steps:
     return object.visit(
-        // 1. If object is a sequence, then for each header in object:
+        // 1. If object is a sequence, then for each header of object:
         [this](Vector<Vector<DeprecatedString>> const& object) -> WebIDL::ExceptionOr<void> {
             for (auto const& entry : object) {
-                // 1. If header does not contain exactly two items, then throw a TypeError.
+                // 1. If header's size is not 2, then throw a TypeError.
                 if (entry.size() != 2)
                     return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Array must contain header key/value pair"sv };
 
-                // 2. Append (header’s first item, header’s second item) to headers.
+                // 2. Append (header[0], header[1]) to headers.
                 auto header = TRY_OR_RETURN_OOM(realm(), Infrastructure::Header::from_string_pair(entry[0], entry[1].bytes()));
                 TRY(append(move(header)));
             }
             return {};
         },
-        // 2. Otherwise, object is a record, then for each key → value in object, append (key, value) to headers.
+        // 2. Otherwise, object is a record, then for each key → value of object, append (key, value) to headers.
         [this](OrderedHashMap<DeprecatedString, DeprecatedString> const& object) -> WebIDL::ExceptionOr<void> {
             for (auto const& entry : object) {
                 auto header = TRY_OR_RETURN_OOM(realm(), Infrastructure::Header::from_string_pair(entry.key, entry.value));

+ 2 - 2
Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Headers.cpp

@@ -261,7 +261,7 @@ ErrorOr<Vector<Header>> HeaderList::sort_and_combine() const
         names_list.append(header.name);
     auto names = TRY(convert_header_names_to_a_sorted_lowercase_set(names_list));
 
-    // 3. For each name in names:
+    // 3. For each name of names:
     for (auto& name : names) {
         // 1. Let value be the result of getting name from list.
         // 2. Assert: value is not null.
@@ -640,7 +640,7 @@ ErrorOr<bool> is_forbidden_request_header(Header const& header)
         // 1. Let parsedValues be the result of getting, decoding, and splitting value.
         auto parsed_values = TRY(get_decode_and_split_header_value(header.value));
 
-        // 2. For each method in parsedValues: if the isomorphic encoding of method is a forbidden method, then return true.
+        // 2. For each method of parsedValues: if the isomorphic encoding of method is a forbidden method, then return true.
         if (parsed_values.has_value() && any_of(*parsed_values, [](auto method) { return is_forbidden_method(method.bytes()); }))
             return true;
     }

+ 1 - 1
Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp

@@ -153,7 +153,7 @@ bool Request::has_redirect_tainted_origin() const
     // 1. Let lastURL be null.
     Optional<AK::URL const&> last_url;
 
-    // 2. For each url in request’s URL list:
+    // 2. For each url of request’s URL list:
     for (auto const& url : m_url_list) {
         // 1. If lastURL is null, then set lastURL to url and continue.
         if (!last_url.has_value()) {

+ 1 - 1
Userland/Libraries/LibWeb/Fetch/Request.cpp

@@ -413,7 +413,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> Request::construct_impl(JS::Realm
         // 3. Empty this’s headers’s header list.
         request_object->headers()->header_list()->clear();
 
-        // 4. If headers is a Headers object, then for each header in its header list, append (header’s name, header’s value) to this’s headers.
+        // 4. If headers is a Headers object, then for each header of its header list, append header to this’s headers.
         if (auto* header_list = headers.get_pointer<JS::NonnullGCPtr<Infrastructure::HeaderList>>()) {
             for (auto& header : *header_list->ptr())
                 TRY(request_object->headers()->append(DeprecatedString::copy(header.name), DeprecatedString::copy(header.value)));