- From: Domenic Denicola <notifications@github.com>
- Date: Wed, 05 Feb 2025 18:14:13 -0800
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/ServiceWorker/pull/1752/review/2597485708@github.com>
@domenic approved this pull request. > + <h3 id="check-router-registration-limit"><dfn>Check Router Registration Limit</dfn></h3> + + : Input + :: |routerRules|, a [=list of router rules=] + : Output + :: a boolean + + Note: Router conditions can be complex and nested using {{RouterCondition/_or}} and {{RouterCondition/not}}. To prevent excessive processing, this algorithm introduces two limits. First, the total number of conditions, counting all nested conditions, cannot exceed 1024. Second, the nesting depth is limited to 10 levels to avoid exponential computation. + + 1. Let |result| be a [=count router condition result=]. + 1. Set |result|'s [=count router condition result/condition count=] to 1024. + 1. Set |result|'s [=count router condition result/quota exceeded=] to false. + 1. [=list/For each=] |rule| of |routerRules|: + 1. Set |result| to be the result of running [=Count Router Inner Conditions=] with |rule|["{{RouterRule/condition}}"], |result|, and 10. + 1. If |result|'s [=count router condition result/quota exceeded=] is true, return false. + 1. return true. ```suggestion 1. Return true. ``` > + <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}}"]: The algorithm seems pretty intuitive to me now without needing a note. It is clear that _result_ is mutated and the for-loop over all `_or` conditions means it will be mutated once for each sub-condition. -- Reply to this email directly or view it on GitHub: https://github.com/w3c/ServiceWorker/pull/1752#pullrequestreview-2597485708 You are receiving this because you are subscribed to this thread. Message ID: <w3c/ServiceWorker/pull/1752/review/2597485708@github.com>
Received on Thursday, 6 February 2025 02:14:17 UTC