Skip to content

Commit

Permalink
Mention URL safety with data: and Base 64 (mdn#34147)
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena authored Jun 14, 2024
1 parent a6d878c commit 3b8be0a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions files/en-us/glossary/base64/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ When the term "Base64" is used on its own to refer to a specific {{glossary("alg
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
```

A common variant is "Base64 URL safe", which omits the padding and replaces `+/` with `-_` to avoid characters that might cause problems in
{{glossary("URL")}} path segments or query parameters.
A common variant is "Base64 URL safe", which omits the padding and replaces `+/` with `-_` to avoid characters that might cause problems in {{glossary("URL")}} path segments or query parameters. You don't need this encoding if you are not putting the data in a path segment or query parameter — for example, [data URLs](/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs) have neither and can use the standard Base64 encoding.

Base64 encoding schemes are commonly used to encode binary data for storage or transfer over media that can only deal with ASCII text (or some superset of ASCII that still falls short of accepting arbitrary binary data). This ensures that the data remains intact without modification during transport. Common applications of Base64 include:

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/http/basics_of_http/data_urls/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ A few examples:

## Encoding data into base64 format

Base64 is a group of binary-to-text encoding schemes that represent binary data in an {{Glossary("ASCII")}} string format by translating it into a radix-64 representation. By consisting only of ASCII characters, base64 strings are generally url-safe, and that's why they can be used to encode data in Data URLs.
Base64 is a group of binary-to-text encoding schemes that represent binary data in an {{Glossary("ASCII")}} string format by translating it into a radix-64 representation. By consisting only of characters permitted by the URL syntax ("URL safe"), we can safely encode binary data in data URLs. Base64 uses the characters `+` and `/`, which may have special meanings in URLs. Because Data URLs have no URL path segments or query parameters, this encoding is safe in this context.

### Encoding in JavaScript

Expand Down

0 comments on commit 3b8be0a

Please sign in to comment.