[Pkg-javascript-commits] [node-spdx-correct] 01/04: Import Upstream version 1.0.2

Sruthi Chandran srud-guest at moszumanska.debian.org
Thu Oct 27 07:44:45 UTC 2016


This is an automated email from the git hooks/post-receive script.

srud-guest pushed a commit to branch master
in repository node-spdx-correct.

commit 92f0bb3f9434ec11284c5ff6adafb9d9b37bb5d0
Author: Sruthi <srud at disroot.org>
Date:   Thu Oct 27 12:58:29 2016 +0530

    Import Upstream version 1.0.2
---
 .npmignore       |   3 +
 .travis.yml      |   8 ++
 LICENSE          |  57 +++++++++
 README.md        |  10 ++
 examples.test.js | 377 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 index.js         | 237 ++++++++++++++++++++++++++++++++++
 package.json     |  27 ++++
 7 files changed, 719 insertions(+)

diff --git a/.npmignore b/.npmignore
new file mode 100644
index 0000000..5c77701
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,3 @@
+.npmignore
+.travis.yml
+**.test.js
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..41d6c79
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,8 @@
+---
+language: "node_js"
+node_js:
+  - "0.10"
+  - "0.11"
+  - "0.12"
+  - "stable"
+sudo: false
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..4b54239
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,57 @@
+SPDX:Apache-2.0
+
+Apache License
+
+Version 2.0, January 2004
+
+http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or it [...]
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combin [...]
+
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+
+(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
+
+(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
+
+(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
+
+(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; o [...]
+
+You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the [...]
+
+8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limit [...]
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor h [...]
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..4289e5c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,10 @@
+```javascript
+var correct = require('spdx-correct');
+var assert = require('assert');
+
+assert.equal(correct('mit'), 'MIT')
+
+assert.equal(correct('Apache 2'), 'Apache-2.0')
+
+assert(correct('No idea what license') === null)
+```
diff --git a/examples.test.js b/examples.test.js
new file mode 100644
index 0000000..716761b
--- /dev/null
+++ b/examples.test.js
@@ -0,0 +1,377 @@
+var test = require('tape');
+var parse = require('spdx-expression-parse');
+var correct = require('./');
+
+function valid(string) {
+  try {
+    parse(string);
+    return true;
+  } catch (e) {
+    return false;
+  }
+}
+
+var examples = {
+  ' Apache License V2': 'Apache-2.0',
+  ' BSD-3-Clause': 'BSD-3-Clause',
+  ' GPL-3.0+': 'GPL-3.0',
+  '"BD-2-Clause"': 'BSD-2-Clause',
+  '"BSD-2-Clause"': 'BSD-2-Clause',
+  '"MIT"': 'MIT',
+  '(LGPL)': 'LGPL-3.0',
+  '2 clause BSD': 'BSD-2-Clause',
+  '2-clause-BSD': 'BSD-2-Clause',
+  '3-Clause BSD': 'BSD-3-Clause',
+  '3-Clause-BSD': 'BSD-3-Clause',
+  '3-clause BSD': 'BSD-3-Clause',
+  'AGPL 3': 'AGPL-3.0',
+  'AGPL 3.0':'AGPL-3.0',
+  'AGPL v3': 'AGPL-3.0',
+  'AGPL': 'AGPL-3.0',
+  'AGPL, Copyright 2014 uh-sem-blee, Co.': 'AGPL-3.0',
+  'AGPL-3': 'AGPL-3.0',
+  'AGPL3': 'AGPL-3.0',
+  'AGPLV3': 'AGPL-3.0',
+  'AGPLv3': 'AGPL-3.0',
+  'AGPLv3+': 'AGPL-3.0',
+  'AOL/MIT': 'MIT',
+  'APACHE 2': 'Apache-2.0',
+  'APACHE 2.0': 'Apache-2.0',
+  'APACHE V2.0': 'Apache-2.0',
+  'APACHE': 'Apache-2.0',
+  'APACHE-2': 'Apache-2.0',
+  'APACHE-2.0': 'Apache-2.0',
+  'APACHE-V2': 'Apache-2.0',
+  'APACHE2': 'Apache-2.0',
+  'APACHE2.0': 'Apache-2.0',
+  'APACHE20': 'Apache-2.0',
+  'APACHE2_0': 'Apache-2.0',
+  'APGLv3': 'AGPL-3.0',
+  'APL 2.0': 'Apache-2.0',
+  'APL': 'Apache-2.0',
+  'APL2': 'Apache-2.0',
+  'APLv2': 'Apache-2.0',
+  'Affero GPL or Commercial': 'AGPL-3.0',
+  'Affero GPL v3': 'AGPL-3.0',
+  'Affero GPL3': 'AGPL-3.0',
+  'Affero General Public License v3': 'AGPL-3.0',
+  'Affero-GPL': 'AGPL-3.0',
+  'Apache ': 'Apache-2.0',
+  'Apache 2 License': 'Apache-2.0',
+  'Apache 2': 'Apache-2.0',
+  'Apache 2.0 License': 'Apache-2.0',
+  'Apache 2.0 http://www.apache.org/licenses/': 'Apache-2.0',
+  'Apache 2.0': 'Apache-2.0',
+  'Apache Licence 2.0': 'Apache-2.0',
+  'Apache Licence v2': 'Apache-2.0',
+  'Apache License 2': 'Apache-2.0',
+  'Apache License 2.': 'Apache-2.0',
+  'Apache License 2.0': 'Apache-2.0',
+  'Apache License V2': 'Apache-2.0',
+  'Apache License V2.0': 'Apache-2.0',
+  'Apache License Version 2.0': 'Apache-2.0',
+  'Apache License Version 2.0,': 'Apache-2.0',
+  'Apache License v2': 'Apache-2.0',
+  'Apache License v2.0': 'Apache-2.0',
+  'Apache License version 2.0': 'Apache-2.0',
+  'Apache License': 'Apache-2.0',
+  'Apache License, 2.0': 'Apache-2.0',
+  'Apache License, Version 2.0': 'Apache-2.0',
+  'Apache License, Version 2.0, http://www.apache.org/licenses/LICENSE-2.0': 'Apache-2.0',
+  'Apache License, v2.0': 'Apache-2.0',
+  'Apache License, version 2': 'Apache-2.0',
+  'Apache Public License v2': 'Apache-2.0',
+  'Apache Public License, Version 2': 'Apache-2.0',
+  'Apache Software License 2.0': 'Apache-2.0',
+  'Apache Software License Version 2': 'Apache-2.0',
+  'Apache V2': 'Apache-2.0',
+  'Apache V2.0': 'Apache-2.0',
+  'Apache Version 2': 'Apache-2.0',
+  'Apache Version 2.0': 'Apache-2.0',
+  'Apache lisence V2': 'Apache-2.0',
+  'Apache lisense 2.0': 'Apache-2.0',
+  'Apache v. 2': 'Apache-2.0',
+  'Apache v2 License': 'Apache-2.0',
+  'Apache v2': 'Apache-2.0',
+  'Apache v2.0': 'Apache-2.0',
+  'Apache version 2': 'Apache-2.0',
+  'Apache version 2.0': 'Apache-2.0',
+  'Apache': 'Apache-2.0',
+  'Apache, Version 2.0': 'Apache-2.0',
+  'Apache, v2.0': 'Apache-2.0',
+  'Apache-2': 'Apache-2.0',
+  'Apache-2.0': 'Apache-2.0',
+  'Apache-License-2.0': 'Apache-2.0',
+  'Apache-V2': 'Apache-2.0',
+  'Apache-v2': 'Apache-2.0',
+  'Apache-v2.0': 'Apache-2.0',
+  'Apache2': 'Apache-2.0',
+  'Apache2.0': 'Apache-2.0',
+  'Apache20': 'Apache-2.0',
+  'ApacheV2': 'Apache-2.0',
+  'Apache_2_0': 'Apache-2.0',
+  'Apachev2': 'Apache-2.0',
+  'Artistic 2.0': 'Artistic-2.0',
+  'Artistic License 2.0': 'Artistic-2.0',
+  'Artistic License': 'Artistic-2.0',
+  'Artistic': 'Artistic-2.0',
+  'Attribution-NonCommercial': 'CC-BY-NC-4.0',
+  'BEER': 'Beerware',
+  'BEERWARE': 'Beerware',
+  'BOOST': 'BSL-1.0',
+  'BS3 3-Clause': 'BSD-3-Clause',
+  'BSD 2-Clause license': 'BSD-2-Clause',
+  'BSD 2-Clause': 'BSD-2-Clause',
+  'BSD 2-clause': 'BSD-2-Clause',
+  'BSD 3 Clause': 'BSD-3-Clause',
+  'BSD 3': 'BSD-3-Clause',
+  'BSD 3-Clause': 'BSD-3-Clause',
+  'BSD 3-clause': 'BSD-3-Clause',
+  'BSD clause 3': 'BSD-3-Clause',
+  'BSD': 'BSD-2-Clause',
+  'BSD-2 Clause': 'BSD-2-Clause',
+  'BSD-2-Clauseno': 'BSD-2-Clause',
+  'BSD-2-clause': 'BSD-2-Clause',
+  'BSD-3 Clause': 'BSD-3-Clause',
+  'BSD-3': 'BSD-3-Clause',
+  'BSD-3-Claude': 'BSD-3-Clause',
+  'BSD2-License': 'BSD-2-Clause',
+  'BSD3': 'BSD-3-Clause',
+  'BSD3-Clause': 'BSD-3-Clause',
+  'Beer-Ware': 'Beerware',
+  'BeerWare': 'Beerware',
+  'Beerware': 'Beerware',
+  'Boost': 'BSL-1.0',
+  'CC BY 3.0': 'CC-BY-3.0',
+  'CC BY 4.0': 'CC-BY-4.0',
+  'CC-BY 3.0': 'CC-BY-3.0',
+  'CC-BY 4.0 International': 'CC-BY-4.0',
+  'Cc-by-3.0': 'CC-BY-3.0',
+  'DWTFYW License': 'WTFPL',
+  'DWTFYW': 'WTFPL',
+  'DWTFYWPL': 'WTFPL',
+  'Do what the fuck you want to public license': 'WTFPL',
+  'Eclipse Public License (EPL)': 'EPL-1.0',
+  'Eclipse Public License + Eclipse Distribution License': 'EPL-1.0',
+  'Eclipse Public License 1.0': 'EPL-1.0',
+  'Eclipse Public License': 'EPL-1.0',
+  'Eclipse Public License, Eclipse Distribution License': 'EPL-1.0',
+  'Eclipse': 'EPL-1.0',
+  'GLP': 'GPL-3.0',
+  'GLPv3': 'GPL-3.0',
+  'GNU Affero GPL 3.0': 'AGPL-3.0',
+  'GNU Affero GPLv3': 'AGPL-3.0',
+  'GNU GENERAL PUBLIC LICENSE Version 2': 'GPL-2.0',
+  'GNU GENERAL PUBLIC LICENSE': 'GPL-3.0',
+  'GNU GLP v3.0': 'GPL-3.0',
+  'GNU GPL 3': 'GPL-3.0',
+  'GNU GPL 3.0': 'GPL-3.0',
+  'GNU GPL V2': 'GPL-2.0',
+  'GNU GPL V3.0': 'GPL-3.0',
+  'GNU GPL v2': 'GPL-2.0',
+  'GNU GPL v2.0': 'GPL-2.0',
+  'GNU GPL v3': 'GPL-3.0',
+  'GNU GPL v3.0': 'GPL-3.0',
+  'GNU GPL ver 3': 'GPL-3.0',
+  'GNU GPL': 'GPL-3.0',
+  'GNU GPLv2': 'GPL-2.0',
+  'GNU GPLv3': 'GPL-3.0',
+  'GNU GPLv3+': 'GPL-3.0',
+  'GNU General Public License v2.0': 'GPL-2.0',
+  'GNU General Public License v3': 'GPL-3.0',
+  'GNU General Public License': 'GPL-3.0',
+  'GNU General Public License, version 2': 'GPL-2.0',
+  'GNU General Public': 'GPL-3.0',
+  'GNU LESSER GENERAL PUBLIC LICENSE': 'GPL-3.0',
+  'GNU LGPL v3.0': 'GPL-3.0',
+  'GNU License v3': 'GPL-3.0',
+  'GNU V3': 'GPL-3.0',
+  'GNU v2': 'GPL-2.0',
+  'GNU': 'GPL-3.0',
+  'GNU-GPL': 'GPL-3.0',
+  'GNU/GPL': 'GPL-3.0',
+  'GNU/GPLv2': 'GPL-2.0',
+  'GPL 2': 'GPL-2.0',
+  'GPL 2.0': 'GPL-2.0',
+  'GPL 3': 'GPL-3.0',
+  'GPL 3.0': 'GPL-3.0',
+  'GPL V2': 'GPL-2.0',
+  'GPL V3': 'GPL-3.0',
+  'GPL V3.0': 'GPL-3.0',
+  'GPL Version 3': 'GPL-3.0',
+  'GPL v.2': 'GPL-2.0',
+  'GPL v2': 'GPL-2.0',
+  'GPL v3': 'GPL-3.0',
+  'GPL v3+': 'GPL-3.0',
+  'GPL v3.0': 'GPL-3.0',
+  'GPL': 'GPL-3.0',
+  'GPL-2': 'GPL-2.0',
+  'GPL-2.0-': 'GPL-2.0',
+  'GPL-3': 'GPL-3.0',
+  'GPL-V3': 'GPL-3.0',
+  'GPL2': 'GPL-2.0',
+  'GPL2+': 'GPL-2.0',
+  'GPL3': 'GPL-3.0',
+  'GPL3.0': 'GPL-3.0',
+  'GPL3.0+': 'GPL-3.0',
+  'GPLV2': 'GPL-2.0',
+  'GPLV3': 'GPL-3.0',
+  'GPLv2': 'GPL-2.0',
+  'GPLv2+': 'GPL-2.0',
+  'GPLv3': 'GPL-3.0',
+  'GPLv3+': 'GPL-3.0',
+  'GPLv3.0': 'GPL-3.0',
+  'GUN': 'GPL-3.0',
+  'Gnu public license v2.0': 'GPL-2.0',
+  'Gpl v3': 'GPL-3.0',
+  'Gpl': 'GPL-3.0',
+  'Gpl-2.0': 'GPL-2.0',
+  'Gpl-3.0': 'GPL-3.0',
+  'Gpl2': 'GPL-2.0',
+  'Http://opensource.org/licenses/MIT': 'MIT',
+  'Http://unlicense.org': 'Unlicense',
+  'Http://wtfpl.org/': 'WTFPL',
+  'Http://www.apache.org/licenses/LICENSE-2.0': 'Apache-2.0',
+  'Http://www.mozilla.org/MPL/2.0/': 'MPL-2.0',
+  'Http://www.opensource.org/licenses/MIT': 'MIT',
+  'ISD': 'ISC',
+  'IST': 'ISC',
+  'Isc': 'ISC',
+  'LGLP3': 'LGPL-3.0',
+  'LGPL 2.1': 'LGPL-2.1',
+  'LGPL 3': 'LGPL-3.0',
+  'LGPL 3.0': 'LGPL-3.0',
+  'LGPL Version 3.0': 'LGPL-3.0',
+  'LGPL v2': 'LGPL-2.0',
+  'LGPL v3': 'LGPL-3.0',
+  'LGPL': 'LGPL-3.0',
+  'LGPL-2': 'LGPL-2.0',
+  'LGPL-3': 'LGPL-3.0',
+  'LGPL.v3': 'LGPL-3.0',
+  'LGPL2': 'LGPL-2.0',
+  'LGPL2.1': 'LGPL-2.1',
+  'LGPL3': 'LGPL-3.0',
+  'LGPL3+': 'LGPL-3.0',
+  'LGPL3.0': 'LGPL-3.0',
+  'LGPL:': 'LGPL-3.0',
+  'LGPLv2.1': 'LGPL-2.1',
+  'LGPLv3': 'LGPL-3.0',
+  'LGPLv3+': 'LGPL-3.0',
+  'LICENSE-MIT': 'MIT',
+  'Licenses/GPL-3.0': 'GPL-3.0',
+  'M.I.T': 'MIT',
+  'M.I.T.': 'MIT',
+  'MIT ': 'MIT',
+  'MIT (http://mootools.net/license.txt)': 'MIT',
+  'MIT (https://github.com/AlekseyLeshko/say-me/blob/master/LICENSE)': 'MIT',
+  'MIT (https://github.com/AlekseyLeshko/testimonial.js/blob/master/LICENSE)': 'MIT',
+  'MIT (https://github.com/brentertz/scapegoat/blob/master/LICENSE-MIT)': 'MIT',
+  'MIT / http://rem.mit-license.org': 'MIT',
+  'MIT / http://www.highcharts.com/license/': 'MIT',
+  'MIT 1.0': 'MIT',
+  'MIT <http://bankfacil.mit-license.org>': 'MIT',
+  'MIT <http://opensource.org/licenses/MIT>': 'MIT',
+  'MIT <http://www.opensource.org/licenses/mit-license.php>': 'MIT',
+  'MIT @chetandhembre': 'MIT',
+  'MIT Copyright (c) 2015 Austin Eldridge': 'MIT',
+  'MIT LICENSE': 'MIT',
+  'MIT Licence': 'MIT',
+  'MIT License (MIT)': 'MIT',
+  'MIT License (http://opensource.org/licenses/MIT)': 'MIT',
+  'MIT License - http://opensource.org/licenses/MIT': 'MIT',
+  'MIT License': 'MIT',
+  'MIT License, http://www.opensource.org/licenses/MIT': 'MIT',
+  'MIT License, see LICENSE.md for details': 'MIT',
+  'MIT License. Copyright First Rally. All rights reserved.': 'MIT',
+  'MIT License.': 'MIT',
+  'MIT Licensed. http://www.opensource.org/licenses/mit-license.php': 'MIT',
+  'MIT Lisence': 'MIT',
+  'MIT licence': 'MIT',
+  'MIT license (MIT)': 'MIT',
+  'MIT license': 'MIT',
+  'MIT, Copyright (c) 2013 Michael Schoonmaker': 'MIT',
+  'MIT, http://opensource.org/licenses/MIT': 'MIT',
+  'MIT-LICENSE': 'MIT',
+  'MIT-License': 'MIT',
+  'MIT-Style': 'MIT',
+  'MIT-like': 'MIT',
+  'MIT/X': 'MIT',
+  'MIT/X11': 'MIT',
+  'MIT2': 'MIT',
+  'MITISC': 'MIT',
+  'MIT]': 'MIT',
+  'MIT_License': 'MIT',
+  'MITt': 'MIT',
+  'MPL 2': 'MPL-2.0',
+  'MPL 2.0':'MPL-2.0',
+  'MPL V2': 'MPL-2.0',
+  'MPL v2': 'MPL-2.0',
+  'MPL v2.0': 'MPL-2.0',
+  'MPL': 'MPL-2.0',
+  'MPL-2': 'MPL-2.0',
+  'MPL/2.0': 'MPL-2.0',
+  'MPL2': 'MPL-2.0',
+  'MPL2.0': 'MPL-2.0',
+  'MPLV2': 'MPL-2.0',
+  'MPLv2': 'MPL-2.0',
+  'MPLv2.0': 'MPL-2.0',
+  'MTI': 'MIT',
+  'MiT': 'MIT',
+  'Mit': 'MIT',
+  'Mozilla Public License 1.1': 'MPL-1.1',
+  'Mozilla Public License 2.0': 'MPL-2.0',
+  'Mozilla Public License version 2': 'MPL-2.0',
+  'Mozilla Public License': 'MPL-2.0',
+  'Mozilla Public License, v. 2.0': 'MPL-2.0',
+  'Mozilla Public License, version 2.0': 'MPL-2.0',
+  'Public Domain (UNLISCENSE)': 'Unlicense',
+  'Public Domain (Unlicense)': 'Unlicense',
+  'Public Domain <Unlicense>': 'Unlicense',
+  'Public domain(unlicense)': 'Unlicense',
+  'Public-domain (Unlicense)': 'Unlicense',
+  'Standard 3-clause BSD': 'BSD-3-Clause',
+  'The Unlicense': 'Unlicense',
+  'UNLICENSE': 'Unlicense',
+  'UNLICENSED': 'Unlicense',
+  'UNLICNSE': 'Unlicense',
+  'Unlicence': 'Unlicense',
+  'Unlicense (http://unlicense.org/)': 'Unlicense',
+  'Unlicense (see http://unlicense.org/)': 'Unlicense',
+  'Unlicense': 'Unlicense',
+  'Unlicensed': 'Unlicense',
+  'WTF': 'WTFPL',
+  'WTFGPL': 'WTFPL',
+  'WTFPL 2': 'WTFPL',
+  'WTFPL <http://www.wtfpl.net/>': 'WTFPL',
+  'WTFPLv2': 'WTFPL',
+  'WTHPL v1.0.0': 'WTFPL',
+  'Wtfpl (wtfpl.net)': 'WTFPL',
+  'Wtfpl': 'WTFPL',
+  'ZLIB': 'Zlib',
+  'Zlib': 'Zlib',
+  'Zlib/libpng': 'Zlib',
+  'mit':'MIT',
+  '© 2014 WTFPL – Do What the Fuck You Want to Public License.': 'WTFPL'
+};
+
+test('examples', function(test) {
+  Object.keys(examples)
+    .forEach(function(input) {
+      var corrected = examples[input];
+      test.test(input, function(test) {
+        test.equal(
+          correct(input),
+          corrected,
+          'corrects "' + input + '" to "' + corrected + '"'
+        );
+        if (corrected !== null) {
+          test.ok(
+            valid(corrected),
+            '"' + corrected + '" is a valid SPDX identifier'
+          );
+        }
+        test.end();
+      });
+    });
+  test.end();
+});
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..75b7a21
--- /dev/null
+++ b/index.js
@@ -0,0 +1,237 @@
+var licenseIDs = require('spdx-license-ids');
+
+function valid(string) {
+  return licenseIDs.indexOf(string) > -1;
+}
+
+// Common transpositions of license identifier acronyms
+var transpositions = [
+  ['APGL', 'AGPL'],
+  ['Gpl', 'GPL'],
+  ['GLP', 'GPL'],
+  ['APL', 'Apache'],
+  ['ISD', 'ISC'],
+  ['GLP', 'GPL'],
+  ['IST', 'ISC'],
+  ['Claude', 'Clause'],
+  [' or later', '+'],
+  [' International', ''],
+  ['GNU', 'GPL'],
+  ['GUN', 'GPL'],
+  ['+', ''],
+  ['GNU GPL', 'GPL'],
+  ['GNU/GPL', 'GPL'],
+  ['GNU GLP', 'GPL'],
+  ['GNU General Public License', 'GPL'],
+  ['Gnu public license', 'GPL'],
+  ['GNU Public License', 'GPL'],
+  ['GNU GENERAL PUBLIC LICENSE', 'GPL'],
+  ['MTI', 'MIT'],
+  ['Mozilla Public License', 'MPL'],
+  ['WTH', 'WTF'],
+  ['-License', '']
+];
+
+var TRANSPOSED = 0;
+var CORRECT = 1;
+
+// Simple corrections to nearly valid identifiers.
+var transforms = [
+  // e.g. 'mit'
+  function(argument) {
+    return argument.toUpperCase();
+  },
+  // e.g. 'MIT '
+  function(argument) {
+    return argument.trim();
+  },
+  // e.g. 'M.I.T.'
+  function(argument) {
+    return argument.replace(/\./g, '');
+  },
+  // e.g. 'Apache- 2.0'
+  function(argument) {
+    return argument.replace(/\s+/g, '');
+  },
+  // e.g. 'CC BY 4.0''
+  function(argument) {
+    return argument.replace(/\s+/g, '-');
+  },
+  // e.g. 'LGPLv2.1'
+  function(argument) {
+    return argument.replace('v', '-');
+  },
+  // e.g. 'Apache 2.0'
+  function(argument) {
+    return argument.replace(/,?\s*(\d)/, '-$1');
+  },
+  // e.g. 'GPL 2'
+  function(argument) {
+    return argument.replace(/,?\s*(\d)/, '-$1.0');
+  },
+  // e.g. 'Apache Version 2.0'
+  function(argument) {
+    return argument.replace(/,?\s*(V\.|v\.|V|v|Version|version)\s*(\d)/, '-$2');
+  },
+  // e.g. 'Apache Version 2'
+  function(argument) {
+    return argument.replace(/,?\s*(V\.|v\.|V|v|Version|version)\s*(\d)/, '-$2.0');
+  },
+  // e.g. 'ZLIB'
+  function(argument) {
+    return argument[0].toUpperCase() + argument.slice(1);
+  },
+  // e.g. 'MPL/2.0'
+  function(argument) {
+    return argument.replace('/', '-');
+  },
+  // e.g. 'Apache 2'
+  function(argument) {
+    return argument
+      .replace(/\s*V\s*(\d)/, '-$1')
+      .replace(/(\d)$/, '$1.0');
+  },
+  // e.g. 'GPL-2.0-'
+  function(argument) {
+    return argument.slice(0, argument.length - 1);
+  },
+  // e.g. 'GPL2'
+  function(argument) {
+    return argument.replace(/(\d)$/, '-$1.0');
+  },
+  // e.g. 'BSD 3'
+  function(argument) {
+    return argument.replace(/(-| )?(\d)$/, '-$2-Clause');
+  },
+  // e.g. 'BSD clause 3'
+  function(argument) {
+    return argument.replace(/(-| )clause(-| )(\d)/, '-$3-Clause');
+  },
+  // e.g. 'BY-NC-4.0'
+  function(argument) {
+    return 'CC-' + argument;
+  },
+  // e.g. 'BY-NC'
+  function(argument) {
+    return 'CC-' + argument + '-4.0';
+  },
+  // e.g. 'Attribution-NonCommercial'
+  function(argument) {
+    return argument
+      .replace('Attribution', 'BY')
+      .replace('NonCommercial', 'NC')
+      .replace('NoDerivatives', 'ND')
+      .replace(/ (\d)/, '-$1')
+      .replace(/ ?International/, '');
+  },
+  // e.g. 'Attribution-NonCommercial'
+  function(argument) {
+    return 'CC-' +
+      argument
+      .replace('Attribution', 'BY')
+      .replace('NonCommercial', 'NC')
+      .replace('NoDerivatives', 'ND')
+      .replace(/ (\d)/, '-$1')
+      .replace(/ ?International/, '') +
+      '-4.0';
+  }
+];
+
+// If all else fails, guess that strings containing certain substrings
+// meant to identify certain licenses.
+var lastResorts = [
+  ['UNLI', 'Unlicense'],
+  ['WTF', 'WTFPL'],
+  ['2 CLAUSE', 'BSD-2-Clause'],
+  ['2-CLAUSE', 'BSD-2-Clause'],
+  ['3 CLAUSE', 'BSD-3-Clause'],
+  ['3-CLAUSE', 'BSD-3-Clause'],
+  ['AFFERO', 'AGPL-3.0'],
+  ['AGPL', 'AGPL-3.0'],
+  ['APACHE', 'Apache-2.0'],
+  ['ARTISTIC', 'Artistic-2.0'],
+  ['Affero', 'AGPL-3.0'],
+  ['BEER', 'Beerware'],
+  ['BOOST', 'BSL-1.0'],
+  ['BSD', 'BSD-2-Clause'],
+  ['ECLIPSE', 'EPL-1.0'],
+  ['FUCK', 'WTFPL'],
+  ['GNU', 'GPL-3.0'],
+  ['LGPL', 'LGPL-3.0'],
+  ['GPL', 'GPL-3.0'],
+  ['MIT', 'MIT'],
+  ['MPL', 'MPL-2.0'],
+  ['X11', 'X11'],
+  ['ZLIB', 'Zlib']
+];
+
+var SUBSTRING = 0;
+var IDENTIFIER = 1;
+
+var validTransformation = function(identifier) {
+  for (var i = 0; i < transforms.length; i++) {
+    var transformed = transforms[i](identifier);
+    if (transformed !== identifier && valid(transformed)) {
+      return transformed;
+    }
+  }
+  return null;
+};
+
+var validLastResort = function(identifier) {
+  var upperCased = identifier.toUpperCase();
+  for (var i = 0; i < lastResorts.length; i++) {
+    var lastResort = lastResorts[i];
+    if (upperCased.indexOf(lastResort[SUBSTRING]) > -1) {
+      return lastResort[IDENTIFIER];
+    }
+  }
+  return null;
+};
+
+var anyCorrection = function(identifier, check) {
+  for (var i = 0; i < transpositions.length; i++) {
+    var transposition = transpositions[i];
+    var transposed = transposition[TRANSPOSED];
+    if (identifier.indexOf(transposed) > -1) {
+      var corrected = identifier.replace(
+        transposed,
+        transposition[CORRECT]
+      );
+      var checked = check(corrected);
+      if (checked !== null) {
+        return checked;
+      }
+    }
+  }
+  return null;
+};
+
+module.exports = function(identifier) {
+  identifier = identifier.replace(/\+$/, '');
+  if (valid(identifier)) {
+    return identifier;
+  }
+  var transformed = validTransformation(identifier);
+  if (transformed !== null) {
+    return transformed;
+  }
+  transformed = anyCorrection(identifier, function(argument) {
+    if (valid(argument)) {
+      return argument;
+    }
+    return validTransformation(argument);
+  });
+  if (transformed !== null) {
+    return transformed;
+  }
+  transformed = validLastResort(identifier);
+  if (transformed !== null) {
+    return transformed;
+  }
+  transformed = anyCorrection(identifier, validLastResort);
+  if (transformed !== null) {
+    return transformed;
+  }
+  return null;
+};
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..f02654a
--- /dev/null
+++ b/package.json
@@ -0,0 +1,27 @@
+{
+  "name": "spdx-correct",
+  "description": "correct invalid SPDX identifiers",
+  "version": "1.0.2",
+  "author": "Kyle E. Mitchell <kyle at kemitchell.com> (https://kemitchell.com)",
+  "dependencies": {
+    "spdx-license-ids": "^1.0.2"
+  },
+  "devDependencies": {
+    "defence-cli": "^1.0.1",
+    "replace-require-self": "^1.0.0",
+    "spdx-expression-parse": "^1.0.0",
+    "tape": "~4.0.0"
+  },
+  "keywords": [
+    "SPDX",
+    "law",
+    "legal",
+    "license",
+    "metadata"
+  ],
+  "license": "Apache-2.0",
+  "repository": "kemitchell/spdx-correct.js",
+  "scripts": {
+    "test": "defence README.md | replace-require-self | node && tape *.test.js"
+  }
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-spdx-correct.git



More information about the Pkg-javascript-commits mailing list