WICG / service-worker-static-routing-api

A repository for the ServiceWorker static routing API.
Other
24 stars 6 forks source link

How an empty list is handled with "and" / "or"? #9

Closed yoshisatoyanagisawa closed 10 months ago

yoshisatoyanagisawa commented 11 months ago

When we introduce "and" / "or" syntax to the static routing API, people may set an empty list there. What is an expected behavior for it? I suppose there are two options: Option 1. accept an empty list, but an empty list for "and" means matching anything while an empty list for "or" means matching nothing. Option 2. raise error if an empty list is set to "and" / "or".

Since I do not come up with a use case that need Option 1., I lean on Option 2 to avoid developers to make mistakes. What do you think?

azaika commented 11 months ago

One possible case that needs Option 1 is the case where router rules are generated dynamically, for example, by some transpilers.

domenic commented 10 months ago

Option 1. accept an empty list, but an empty list for "and" means matching anything while an empty list for "or" means matching nothing.

This is the canonical way in which and/or are handled in programming, including in speculation rules. I suggest we go this direction.

yoshisatoyanagisawa commented 10 months ago

Thanks for the comments both. For ease of understanding the condition, let's go with Option 1.