diff --git a/licenses/find.go b/licenses/find.go index 1813176..d189f9a 100644 --- a/licenses/find.go +++ b/licenses/find.go @@ -24,7 +24,7 @@ import ( ) var ( - licenseRegexp = regexp.MustCompile(`^(?i)(LICEN(S|C)E|COPYING|README|NOTICE).*$`) + licenseRegexp = regexp.MustCompile(`^(?i)((UN)?LICEN(S|C)E|COPYING|README|NOTICE).*$`) ) // Find returns the file path of the license for this package. diff --git a/licenses/find_test.go b/licenses/find_test.go index 10f679b..47ae5af 100644 --- a/licenses/find_test.go +++ b/licenses/find_test.go @@ -37,6 +37,7 @@ func TestFind(t *testing.T) { "testdata/readme/README.md": "foo", "testdata/lowercase/license": "foo", "testdata/license-apache-2.0/LICENSE-APACHE-2.0.txt": "foo", + "testdata/unlicense/UNLICENSE": "unlicense", }, licenseTypes: map[string]Type{ "testdata/LICENSE": Notice, @@ -47,6 +48,7 @@ func TestFind(t *testing.T) { "testdata/readme/README.md": Notice, "testdata/lowercase/license": Notice, "testdata/license-apache-2.0/LICENSE-APACHE-2.0.txt": Notice, + "testdata/unlicense/UNLICENSE": Unencumbered, }, } @@ -108,6 +110,11 @@ func TestFind(t *testing.T) { rootDir: "testdata/proprietary-license", wantErr: regexp.MustCompile(`cannot find a known open source license for.*testdata/proprietary-license.*whose name matches regexp.*and locates up until.*testdata/proprietary-license`), }, + { + desc: "UNLICENSE", + dir: "testdata/unlicense", + wantLicensePath: filepath.Join(wd, "testdata/unlicense/UNLICENSE"), + }, } { t.Run(test.desc, func(t *testing.T) { if test.rootDir == "" { diff --git a/licenses/testdata/unlicense/UNLICENSE b/licenses/testdata/unlicense/UNLICENSE new file mode 100644 index 0000000..00d2e13 --- /dev/null +++ b/licenses/testdata/unlicense/UNLICENSE @@ -0,0 +1,24 @@ +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to \ No newline at end of file