Re: [w3c/ServiceWorker] Add limits to the number of router rule registration (PR #1752)

@sisidovski commented on this pull request.



> +    <h3 id="count-router-inner-conditions"><dfn>Count Router Inner Conditions</dfn></h3>
+
+      : Input
+      :: |condition|, a {{RouterCondition}}
+      :: |result|, a [=count router condition result=]
+      :: |maxCount|, a number
+      :: |maxDepth|, a number
+      : Output
+      :: |result|, a [=count router condition result=]
+
+      1. Increment |result|'s [=count router condition result/total count=] by one.
+      1. If |result|'s [=count router condition result/total count=] exceeds |maxCount|, return |result|.
+      1. If |result|'s [=count router condition result/depth=] exceeds |maxDepth|, return |result|.
+      1. If |condition|["{{RouterCondition/_or}}"] [=map/exists=], then:
+          1. Increment |result|'s [=count router condition result/depth=] by one.
+          1. For each |orCondition| of |condition|["{{RouterCondition/_or}}"]:

I believe those are correctly counted? Let's walk through the current algorithm. btw, under the current design, `or: [{singleRule}, {singleRule}, {singleRule}]`, this total count is expected to be four (`or` should be counted as one condition).

1. We call count-router-inner-conditions with the root `or` condition. The total count will be one.
2. Starts the for loop with the first {singleRule}.
3. In the first sub-step, |result|'s `total count` will be two, because we pass "one" as `total count` to count-router-inner-conditions in this sub-step. `total count` will be incremented inside the algorithm.
4. The second {singleRule} is handled. `total count` will be three.
5. The third {singleRule} is handled. `total count` will be four.

Am I missing something?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/pull/1752#discussion_r1938663169
You are receiving this because you are subscribed to this thread.

Message ID: <w3c/ServiceWorker/pull/1752/review/2588745217@github.com>

Received on Monday, 3 February 2025 01:51:01 UTC