Skip to content

Instantly share code, notes, and snippets.

@fitzgen
Last active April 26, 2024 20:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fitzgen/35d7e3905a915238aa14 to your computer and use it in GitHub Desktop.
Save fitzgen/35d7e3905a915238aa14 to your computer and use it in GitHub Desktop.
# Proposed Format
{
...
7. sources: ["baz.ts", "foo.js", "bar.js"]
...
9. mediaTypes: ["application/javascript", "application/x.typescript"],
10. sourcesMediaTypes: "CAA",
}
Line 9: A list containing the set of each media type M such that there is a
source whose associated media media type is M in the "sources" property. Media
types must conform to https://www.rfc-editor.org/rfc/rfc6838.txt.
Line 10: A string containing a list of base 64 VLQ encoded integers greater than
or equal to 0 with no separators. The number of integers encoded must not exceed
the length of the "sources" property.
To find a source S's associated media type:
1. Let sourceIndex be the index of S in the "sources" property.
2. Let sourcesMediaTypesLength be the number of integers encoded in the
"sourcesMediaTypes" property.
3. If sourceIndex >= sourcesMediaTypesLength, let mediaTypeIndex be 0.
4. Else, let mediaTypeIndex be the integer at sourceIndex in the base 64 VLQ
encoded "sourcesMediaTypes" property.
5. If mediaTypeIndex >= the length of the "mediaTypes" property, the return
value is undefined.
5. Return the media type at mediaTypeIndex in the "mediaTypes" property.
Note that in the above algorithm, lists of size N are indexed from 0 to N-1.
@concavelenz
Copy link

This should explicitly state that these fields are optional and the second is invalid if the first is not present and that the absence doesn't imply anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment