Skip to content

Commit 0a11647

Browse files
committed
Update get matching cookies algorithm to make it more convenient for implementation.
1 parent f070ceb commit 0a11647

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

index.bs

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9490,6 +9490,25 @@ keys for which no default is available. As such the list must not share any
94909490
entries with the keys of [=default values for storage partition key
94919491
attributes=].
94929492

9493+
<div algorithm>
9494+
To <dfn>deserialize filter</dfn> given |filter|:
9495+
9496+
1. Let |deserialized filter| to be an empty [=/map=].
9497+
9498+
1. For each |name| → |value| in |filter|:
9499+
9500+
1. Let |deserialized name| be the field name corresponding to the JSON key |name| in
9501+
the [=table for cookie conversion=].
9502+
9503+
1. If |name| is "<code>value</code>", set |deserialized value| to [=deserialize protocol bytes=] with |value|,
9504+
otherwise let |deserialized value| be |value|.
9505+
9506+
1. [=map/Set=] |deserialized filter|[|deserialized name|] to |deserialized value|.
9507+
9508+
1. Return |deserialized filter|.
9509+
9510+
</div>
9511+
94939512
<div algorithm>
94949513
To <dfn>expand a storage partition spec</dfn> given |partition spec|:
94959514

@@ -9545,17 +9564,7 @@ To <dfn>match cookie</dfn> given |stored cookie| and |filter|:
95459564

95469565
1. For each |name| → |value| in |filter|:
95479566

9548-
1. If |name| is "<code>value</code>":
9549-
9550-
1. Set |value| to [=deserialize protocol bytes=] with |value|.
9551-
9552-
1. Let |field name| be the field name corresponding to the JSON key |name| in
9553-
the [=table for cookie conversion=].
9554-
9555-
1. If |field name| is "<code>value</code>", set |store cookie value| to [=deserialize protocol bytes=] with |stored cookie|["value"],
9556-
Otherwise let |store cookie value| be |stored cookie|[|field name|].
9557-
9558-
1. If |store cookie value| does not equal |value|:
9567+
1. If |stored cookie|[|name|] does not equal |value|:
95599568

95609569
1. Return false.
95619570

@@ -9568,13 +9577,13 @@ To <dfn>get matching cookies</dfn> given |cookie store| and |filter|:
95689577

95699578
1. Let |cookies| be a new list.
95709579

9571-
1. For each |stored cookie| in |cookie store|:
9580+
1. Set |deserialized filter| to [=deserialize filter=] with |filter|.
95729581

9573-
1. Let |serialized cookie| be the result of [=serialize cookie=] given |stored cookie|.
9582+
1. For each |stored cookie| in |cookie store|:
95749583

9575-
1. If [=match cookie=] with |serialized cookie| and |filter| is true:
9584+
1. If [=match cookie=] with |stored cookie| and |deserialized filter| is true:
95769585

9577-
1. Append |serialized cookie| to |cookies|.
9586+
1. Append |stored cookie| to |cookies|.
95789587

95799588
1. Return |cookies|.
95809589

@@ -9662,8 +9671,16 @@ The [=remote end steps=] with <var ignore>session</var> and |command parameters|
96629671

96639672
1. Let |cookies| be the result of [=get matching cookies=] with |store| and |filter|.
96649673

9674+
1. Let |serialized cookies| be a new list.
9675+
9676+
1. For each |cookie| in |cookies|:
9677+
9678+
1. Let |serialized cookie| be the result of [=serialize cookie=] given |cookie|.
9679+
9680+
1. Append |serialized cookie| to |serialized cookies|.
9681+
96659682
1. Let |body| be a [=/map=] matching the <code>storage.GetCookiesResult</code> production,
9666-
with the <code>cookies</code> field set to |cookies| and the <code>partitionKey</code>
9683+
with the <code>cookies</code> field set to |serialized cookies| and the <code>partitionKey</code>
96679684
field set to |partition key|.
96689685

96699686
1. Return [=success=] with data |body|.

0 commit comments

Comments
 (0)