@@ -41,7 +41,6 @@ import qualified Data.Text.Lazy.Encoding as TL
4141
4242import Control.Category ((>>>))
4343import Control.Arrow ((***))
44−import Control.Applicative ((<|>))
4544import Control.Exception (catch, try)
4645import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)
4746import Control.Monad.Trans.Except
@@ -197,8 +196,7 @@ getBowerInfo = either (userError . BadRepositoryField) return . tryExtract
197196 maybe (Left NotOnGithub) Right (extractGithub repositoryUrl)
198197
199198extractGithub :: String -> Maybe (D.GithubUser, D.GithubRepo)
200−extractGithub =
201− matchUrl
199+extractGithub = stripGitHubPrefixes
202200 >>> fmap (splitOn "/")
203201 >=> takeTwo
204202 >>> fmap (D.GithubUser *** (D.GithubRepo . dropDotGit))
@@ -208,15 +206,20 @@ extractGithub =
208206 takeTwo [x, y] = Just (x, y)
209207 takeTwo _ = Nothing
210208
209+ stripGitHubPrefixes :: String -> Maybe String
210+ stripGitHubPrefixes = stripPrefixes [ "git://github.com/"
211+ , "https://github.com/"
212+ , "git@github.com:"
213+ ]
214+
215+ stripPrefixes :: [String] -> String -> Maybe String
216+ stripPrefixes prefixes str = msum $ (`stripPrefix` str) <$> prefixes
217+
211218 dropDotGit :: String -> String
212219 dropDotGit str
213220 | ".git" `isSuffixOf` str = take (length str - 4) str
214221 | otherwise = str
215222
216− matchUrl :: String -> Maybe String
217− matchUrl str =
218− stripPrefix "git@github.com:" str <|> stripPrefix "git://github.com/" str
219−
220223readProcess' :: String -> [String] -> String -> PrepareM String
221224readProcess' prog args stdin = do
222225 out <- liftIO (catch (Right <$> readProcess prog args stdin)