@readme/data-urls 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## <small>1.0.1 (2022-07-27)</small>
2
+
3
+ * fix: don't lowercase `name` attributes - some filesystems are case-sensitive ([7b43a4d](https://github.com/readmeio/data-urls/commit/7b43a4d))
4
+ * docs: adding a changelog ([5218189](https://github.com/readmeio/data-urls/commit/5218189))
5
+
6
+
7
+
1
8
  ## 1.0.0 (2022-07-27)
2
9
 
3
10
  * docs: adding some demos to the readme ([dd6316f](https://github.com/readmeio/data-urls/commit/dd6316f))
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ declare function validate(str: string): boolean;
10
10
  export declare type DataURL = {
11
11
  mediaType?: string;
12
12
  contentType?: string;
13
+ name?: string;
13
14
  base64: boolean;
14
15
  data: string;
15
16
  toBuffer: () => Buffer;
package/dist/index.js CHANGED
@@ -27,7 +27,14 @@ function parse(str) {
27
27
  var parsed = {};
28
28
  if (parts[1]) {
29
29
  parsed.mediaType = parts[1].toLowerCase();
30
- var mediaTypeParts = parts[1].split(';').map(function (x) { return x.toLowerCase(); });
30
+ var mediaTypeParts = parts[1].split(';').map(function (x) {
31
+ // `name` attributes are for filenames so we shouldn't lowercase them as some filesystems are
32
+ // case-sensitive.
33
+ if (x.startsWith('name=')) {
34
+ return x;
35
+ }
36
+ return x.toLowerCase();
37
+ });
31
38
  parsed.contentType = mediaTypeParts[0];
32
39
  mediaTypeParts.slice(1).forEach(function (attribute) {
33
40
  var p = attribute.split('=');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readme/data-urls",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A utility for parsing and validating data URLs.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -16,6 +16,7 @@ function validate(str: string) {
16
16
  export type DataURL = {
17
17
  mediaType?: string;
18
18
  contentType?: string;
19
+ name?: string;
19
20
  base64: boolean;
20
21
  data: string;
21
22
  toBuffer: () => Buffer;
@@ -37,7 +38,15 @@ function parse(str: string) {
37
38
  if (parts[1]) {
38
39
  parsed.mediaType = parts[1].toLowerCase();
39
40
 
40
- const mediaTypeParts = parts[1].split(';').map(x => x.toLowerCase());
41
+ const mediaTypeParts = parts[1].split(';').map(x => {
42
+ // `name` attributes are for filenames so we shouldn't lowercase them as some filesystems are
43
+ // case-sensitive.
44
+ if (x.startsWith('name=')) {
45
+ return x;
46
+ }
47
+
48
+ return x.toLowerCase();
49
+ });
41
50
 
42
51
  parsed.contentType = mediaTypeParts[0];
43
52