fromkey, registerurl: Improve handling of urls that happen to also be parsable as strange keys.

This commit is contained in:
Joey Hess 2015-05-30 02:08:49 -04:00
parent fa38fe0cf6
commit 36b9c9ca5f
3 changed files with 25 additions and 5 deletions

View file

@ -16,6 +16,7 @@ module Types.Key (
nonChunkKey,
chunkKeyOffset,
isChunkKey,
isKeyPrefix,
prop_idempotent_key_encode,
prop_idempotent_key_decode
@ -66,6 +67,10 @@ chunkKeyOffset k = (*)
isChunkKey :: Key -> Bool
isChunkKey k = isJust (keyChunkSize k) && isJust (keyChunkNum k)
-- Checks if a string looks like at least the start of a key.
isKeyPrefix :: String -> Bool
isKeyPrefix s = [fieldSep, fieldSep] `isInfixOf` s
fieldSep :: Char
fieldSep = '-'