diff --git a/Cabal/Distribution/SPDX/LicenseExceptionId.hs b/Cabal/Distribution/SPDX/LicenseExceptionId.hs index c0c49851bcd..b4d53cb2417 100644 --- a/Cabal/Distribution/SPDX/LicenseExceptionId.hs +++ b/Cabal/Distribution/SPDX/LicenseExceptionId.hs @@ -137,7 +137,7 @@ licenseExceptionName WxWindows_exception_3_1 = "WxWindows Library Exception 3.1" -- | Create a 'LicenseExceptionId' from a 'String'. mkLicenseExceptionId :: String -> Maybe LicenseExceptionId -mkLicenseExceptionId s = Map.lookup s stringLookup +mkLicenseExceptionId s = Map.lookup (map toLower s) stringLookup stringLookup :: Map String LicenseExceptionId -stringLookup = Map.fromList $ map (\i -> (licenseExceptionId i, i)) $ [minBound .. maxBound] +stringLookup = Map.fromList $ map (\i -> (map toLower (licenseExceptionId i), i)) $ [minBound .. maxBound] diff --git a/Cabal/Distribution/SPDX/LicenseId.hs b/Cabal/Distribution/SPDX/LicenseId.hs index 0942ada40f4..cb030a749cc 100644 --- a/Cabal/Distribution/SPDX/LicenseId.hs +++ b/Cabal/Distribution/SPDX/LicenseId.hs @@ -1479,7 +1479,7 @@ licenseIsOsiApproved ZPL_2_1 = False -- | Create a 'LicenseId' from a 'String'. mkLicenseId :: String -> Maybe LicenseId -mkLicenseId s = Map.lookup s stringLookup +mkLicenseId s = Map.lookup (map toLower s) stringLookup stringLookup :: Map String LicenseId -stringLookup = Map.fromList $ map (\i -> (licenseId i, i)) $ [minBound .. maxBound] +stringLookup = Map.fromList $ map (\i -> (map toLower (licenseId i), i)) $ [minBound .. maxBound] diff --git a/Cabal/tests/UnitTests/Distribution/SPDX.hs b/Cabal/tests/UnitTests/Distribution/SPDX.hs index eaabcc6b647..b4dd477d5b6 100644 --- a/Cabal/tests/UnitTests/Distribution/SPDX.hs +++ b/Cabal/tests/UnitTests/Distribution/SPDX.hs @@ -14,7 +14,9 @@ import Test.Tasty.QuickCheck spdxTests :: [TestTree] spdxTests = [ testProperty "LicenseId roundtrip" licenseIdRoundtrip + , testProperty "LicenseId roundtrip (lower case)" licenseIdRoundtripLowerCase , testProperty "LicenseExceptionId roundtrip" licenseExceptionIdRoundtrip + , testProperty "LicenseExceptionId roundtrip (lower case)" licenseExceptionIdRoundtripLowerCase , testProperty "LicenseRef roundtrip" licenseRefRoundtrip , testProperty "SimpleLicenseExpression roundtrip" simpleLicenseExpressionRoundtrip , testProperty "LicenseExpression roundtrip" licenseExpressionRoundtrip @@ -27,11 +29,21 @@ licenseIdRoundtrip x = counterexample (prettyShow x) $ Right x === eitherParsec (prettyShow x) +licenseIdRoundtripLowerCase :: LicenseId -> Property +licenseIdRoundtripLowerCase x = + counterexample (prettyShow x) $ + Right x === eitherParsec (map toLower $ prettyShow x) + licenseExceptionIdRoundtrip :: LicenseExceptionId -> Property licenseExceptionIdRoundtrip x = counterexample (prettyShow x) $ Right x === eitherParsec (prettyShow x) +licenseExceptionIdRoundtripLowerCase :: LicenseExceptionId -> Property +licenseExceptionIdRoundtripLowerCase x = + counterexample (prettyShow x) $ + Right x === eitherParsec (map toLower $ prettyShow x) + licenseRefRoundtrip :: LicenseRef -> Property licenseRefRoundtrip x = counterexample (prettyShow x) $