@callstack/licenses 0.3.1 → 0.3.2

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.
@@ -62,7 +62,13 @@ function prepareAboutLibrariesLicenseField(license) {
62
62
  if (!license.type) {
63
63
  return '';
64
64
  }
65
- return `${license.type}_${(0, miscUtils_1.sha512)(license.content ?? license.type)}`;
65
+ // The returned value is used as a filename under `android/config/licenses/`.
66
+ // Legacy/compound SPDX expressions like `MIT/X11` or `(MIT OR Apache-2.0)` would
67
+ // otherwise produce paths containing `/`, `(` or spaces, which causes the writer
68
+ // to either fail with ENOENT (when a `/` is interpreted as a subdirectory) or
69
+ // to produce names that are invalid on some filesystems.
70
+ const sanitizedType = license.type.replace(/[^A-Za-z0-9._-]/g, '_');
71
+ return `${sanitizedType}_${(0, miscUtils_1.sha512)(license.content ?? sanitizedType)}`;
66
72
  }
67
73
  function parseAuthorField(json) {
68
74
  if (typeof json.author === 'object' && typeof json.author.name === 'string') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@callstack/licenses",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "API package that exposes functionalities for programmatic scanning of licenses in Node.js projects.",
5
5
  "browser": "./build/index.js",
6
6
  "main": "./build/node/index.js",
@@ -59,7 +59,14 @@ export function prepareAboutLibrariesLicenseField(license: License) {
59
59
  return '';
60
60
  }
61
61
 
62
- return `${license.type}_${sha512(license.content ?? license.type)}`;
62
+ // The returned value is used as a filename under `android/config/licenses/`.
63
+ // Legacy/compound SPDX expressions like `MIT/X11` or `(MIT OR Apache-2.0)` would
64
+ // otherwise produce paths containing `/`, `(` or spaces, which causes the writer
65
+ // to either fail with ENOENT (when a `/` is interpreted as a subdirectory) or
66
+ // to produce names that are invalid on some filesystems.
67
+ const sanitizedType = license.type.replace(/[^A-Za-z0-9._-]/g, '_');
68
+
69
+ return `${sanitizedType}_${sha512(license.content ?? sanitizedType)}`;
63
70
  }
64
71
 
65
72
  export function parseAuthorField(json: { author: string | { name: string } }) {