Skip to content

Commit

Permalink
Merge pull request #129 from szuend/extract-verify-vlq-string
Browse files Browse the repository at this point in the history
Editorial: Extract 'validate base64 VLQ groupings' algorithm
  • Loading branch information
jkup authored Sep 26, 2024
2 parents eb86a23 + 3fbeac8 commit f7efad9
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions source-map.bs
Original file line number Diff line number Diff line change
Expand Up @@ -472,18 +472,7 @@ To <dfn>decode source map mappings</dfn> given a [=string=]
<dfn for="decode source map mappings">|mappings|</dfn>, a [=list=] of [=strings=]
<dfn for="decode source map mappings">|names|</dfn>, and a [=list=] of [=decoded source|decoded
sources=] <dfn for="decode source map mappings">|sources|</dfn>, run the following steps:
1. If |mappings| is not an [=ASCII string=], throw an error.
1. If |mappings| contains any [=code unit=] other than:
- U+002C (,) or U+003B (;);
- U+0030 (0) to U+0039 (9);
- U+0041 (A) to U+005A (Z);
- U+0061 (a) to U+007A (z);
- U+002B (+), U+002F (/)

NOTE: These are the valid [[base64]] characters (excluding the padding character `=`), together
with `,` and `;`.

then throw an error.
1. [=Validate base64 VLQ groupings=] with |mappings|.
1. Let |decodedMappings| be a new empty [=list=].
1. Let |groups| be the result of [=strictly split|strictly splitting=] |mappings| on `;`.
1. Let |generatedLine| be 0.
Expand Down Expand Up @@ -545,6 +534,20 @@ sources=] <dfn for="decode source map mappings">|sources|</dfn>, run the followi
1. Increase |generatedLine| by 1.
1. Return |decodedMappings|.

To <dfn>validate base64 VLQ groupings</dfn> from a [=string=] |groupings|, run the following steps:
1. If |groupings| is not an [=ASCII string=], throw an error.
1. If |groupings| contains any [=code unit=] other than:
- U+002C (,) or U+003B (;);
- U+0030 (0) to U+0039 (9);
- U+0041 (A) to U+005A (Z);
- U+0061 (a) to U+007A (z);
- U+002B (+), U+002F (/)

NOTE: These are the valid [[base64]] characters (excluding the padding character `=`), together
with `,` and `;`.

then throw an error.

To <dfn>decode a base64 VLQ</dfn> from a [=string=] |segment| given a [=position variable=]
|position|, run the following steps:
1. If |position| points to the end of |segment|, return null.
Expand Down

0 comments on commit f7efad9

Please sign in to comment.