Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix router rule initialization #3

Conversation

azaika
Copy link

@azaika azaika commented Dec 15, 2023

The list of router rules of service worker is currently initialized as if it is a flag, but it is actually a list.
This PR fix this bug.


Preview | Diff

@yoshisatoyanagisawa
Copy link
Owner

Since the Handle Fetch algorithm checks the existence of the rule with set/unset ("14. Else if registration’s active worker’s list of router rules is set:"), I suppose it fine to leave as-is.

Ah, to run "Let |routerRules| be a copy of |serviceWorker|'s [=list of router rules=]." in https://github.com/yoshisatoyanagisawa/ServiceWorker/pull/2/files as-is, it need to be initialized with an empty set. How about initializing the variable there?

@azaika
Copy link
Author

azaika commented Dec 15, 2023

Since the Handle Fetch algorithm checks the existence of the rule with set/unset ("14. Else if registration’s active worker’s list of router rules is set:"), I suppose it fine to leave as-is.

I suppose that set/unset cannot be used for lists. How about rewriting Step 14 of Handle Fetch algorithm instead?

@yoshisatoyanagisawa
Copy link
Owner

Sounds good to me.
Can I ask @domenic thoughts on the spec perspective?

@@ -3107,7 +3107,7 @@ spec: storage; urlPrefix: https://storage.spec.whatwg.org/
1. Assert: |request|'s [=request/destination=] is not "<code>serviceworker</code>".
1. If |request|'s [=request/destination=] is either "<code>embed</code>" or "<code>object</code>", then:
1. Return null.
1. Else if |registration|'s <a>active worker</a>'s [=service worker/list of router rules=] is set:
1. Else if |registration|'s <a>active worker</a>'s [=service worker/list of router rules=] is [=list/is not empty=]:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is more elegant to remove this condition entirely, since if the list is empty, "Get Router Source" will return null, so the substep will not trigger.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I do not think it is a good idea to ask the intern to work on this after the leave, let me take over the part. I am going to merge this as-is, and will address that in the follow up PR, which might come next year.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, thank you for your comment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is totally OK for me to do such small things as an ooen source contributor, but thanks for your consideration.
Please feel free to ask me if there are any inconvenience due to my work!

@yoshisatoyanagisawa yoshisatoyanagisawa merged commit a44f9a4 into yoshisatoyanagisawa:static_routing_api Dec 18, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants