Skip to content

Commit

Permalink
guess BSD-Source-Code license
Browse files Browse the repository at this point in the history
  • Loading branch information
drewfish committed Feb 15, 2017
1 parent 2529d31 commit b704bc1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/license.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var MIT_LICENSE = /ermission is hereby granted, free of charge, to any/;
var BSD_LICENSE = /edistribution and use in source and binary forms, with or withou/;
var BSD_SOURCE_CODE_LICENSE = /edistribution and use of this software in source and binary forms, with or withou/;
var WTFPL_LICENSE = /DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE/;
var ISC_LICENSE = /The ISC License/;
var MIT = /MIT\b/;
Expand All @@ -23,6 +24,9 @@ module.exports = function(str) {
return 'MIT*';
} else if (BSD_LICENSE.test(str)) {
return 'BSD*';
} else if (BSD_SOURCE_CODE_LICENSE.test(str)) {
// https://spdx.org/licenses/BSD-Source-Code.html
return 'BSD-Source-Code*';
} else if (WTFPL_LICENSE.test(str)) {
return 'WTFPL*';
} else if (ISC.test(str)) {
Expand Down
5 changes: 5 additions & 0 deletions tests/license.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ describe('license parser', function() {
assert.equal(data, 'BSD*');
});

it('BSD-Source-Code check', function() {
var data = license('asdf\nRedistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\nasdf\n');
assert.equal(data, 'BSD-Source-Code*');
});

it('BSD word check', function() {
var data = license('asdf\nasdf\nBSD\nasdf\n');
assert.equal(data, 'BSD*');
Expand Down

0 comments on commit b704bc1

Please sign in to comment.