summaryrefslogtreecommitdiff
path: root/Types/Key.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-05-30 02:08:49 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-05-30 02:08:49 -0400
commitf5060c9334cc0c96f11ee085b74d290c2b1d00db (patch)
treea93b2a7613c8153c8a3b18eb68d84648a976ae33 /Types/Key.hs
parent50301b7bda1854f571b87f3357ee00d6c625af56 (diff)
fromkey, registerurl: Improve handling of urls that happen to also be parsable as strange keys.
Diffstat (limited to 'Types/Key.hs')
-rw-r--r--Types/Key.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/Types/Key.hs b/Types/Key.hs
index 037437303..553fd8f3d 100644
--- a/Types/Key.hs
+++ b/Types/Key.hs
@@ -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 = '-'