bower-license icon indicating copy to clipboard operation
bower-license copied to clipboard

Tolerate object-valued bower license property

Open pkaminski opened this issue 9 years ago • 4 comments

I found at least one Bower package (serialized-lru-cache) that defines its license as:

  "license": {
    "type": "MIT",
    "url": "http://github.com/jmendiara/serialized-lru-cache/raw/master/LICENSE"
  },

No idea if it's spec-compliant or not, but it will crash bower-license and it's a simple fix, so...


This change is Reviewable

pkaminski avatar Apr 10 '16 08:04 pkaminski

I think this is a "bug" in the bower-config of serialized-lru-cache. This type of license definition is not in the spec. This issue should be fixed there and not here. Thanks anyway for finding and reporting!

mojoaxel avatar Apr 11 '16 07:04 mojoaxel

I agree, I don't think the library should be parsing arbitrary specs, but the crashing is not good.

I think what makes sense is simply to check for type:

if (typeof bowerData.license === 'string'){
  moduleInfo.licenses = moduleInfo.licenses.concat(bowerData.license)
}

anacronw avatar Apr 11 '16 07:04 anacronw

OK, I opened a PR against serialized-lru-cache: https://github.com/jmendiara/serialized-lru-cache/pull/1

FWIW, the spec you pointed to also allows an array of strings for the license value, so the type check should probably allow for that.

pkaminski avatar Apr 11 '16 19:04 pkaminski

Fixed in https://github.com/jmendiara/serialized-lru-cache/pull/1 @badunk Can be closed here!

mojoaxel avatar Oct 05 '20 07:10 mojoaxel