Re: [w3c/manifest] Add id member to manifest (#988)

@philloooo commented on this pull request.



> +          <li>Set |manifest|["id"] to |manifest|["start_url"].
+          </li>
+          <li>If the type of |json|["id"] is not [=string=], return.
+          </li>
+          <li>Let |id:URL| be the result of [=URL Parser|parsing=] |json|["id"]
+          with |manifest|["start_ur"]'s origin as the base URL.
+          </li>
+          <li>If |id| is not same origin as |manifest|["start_url"], return.
+          </li>
+          <li>If |id| is failure, return.

I updated the spec to add a final statement of "Otherwise, set manifest["id"] to |id|" And reordered the same origin check and URL processing result check.
It should match 
```javascript
/**
 * @param {Object} json
 * @param {Map<string, any>} manifest
 */
function processIdMember(json, manifest){
  // Set |manifest|["id"] to |manifest|["start_url"].
  manifest.set("id", manifest.get("start_url"));

  // If the type of |json|["id"] is not [=string=], return.
  if (typeof json.id !== "string") return;

  // Let |id:URL| be the result of [=URL Parser|parsing=] |json|["id"]
  // with |manifest|["start_ur"]'s origin as the base URL.
  let id;
  try {
    id = new URL(json.id, manifest.get("start_url").origin);
  } catch {
   // if |id| is failure, return.
    return;
  }

  // If |id| is not same origin as |manifest|["start_url"], return.
  if(id.origin !== manifest.get("start_url").origin)) return;
  
  //Otherwise, set |manifest|["id"] to |id|
  manifest.set("id", id);
}
```

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

Received on Friday, 13 August 2021 21:50:12 UTC