@@ -41,7 +41,6 @@ import qualified Data.Text.Lazy.Encoding as TL
42import Control.Category ((>>>))
42import Control.Category ((>>>))
43import Control.Arrow ((***))
43import Control.Arrow ((***))
44−import Control.Applicative ((<|>))
45import Control.Exception (catch, try)
44import Control.Exception (catch, try)
46import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)
45import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)
47import Control.Monad.Trans.Except
46import Control.Monad.Trans.Except
@@ -197,8 +196,7 @@ getBowerInfo = either (userError . BadRepositoryField) return . tryExtract
197 maybe (Left NotOnGithub) Right (extractGithub repositoryUrl)
196 maybe (Left NotOnGithub) Right (extractGithub repositoryUrl)
199extractGithub :: String -> Maybe (D.GithubUser, D.GithubRepo)
198extractGithub :: String -> Maybe (D.GithubUser, D.GithubRepo)
200−extractGithub =
199+extractGithub = stripGitHubPrefixes
202 >>> fmap (splitOn "/")
200 >>> fmap (splitOn "/")
203 >=> takeTwo
201 >=> takeTwo
204 >>> fmap (D.GithubUser *** (D.GithubRepo . dropDotGit))
202 >>> fmap (D.GithubUser *** (D.GithubRepo . dropDotGit))
@@ -208,15 +206,20 @@ extractGithub =
208 takeTwo [x, y] = Just (x, y)
206 takeTwo [x, y] = Just (x, y)
209 takeTwo _ = Nothing
207 takeTwo _ = Nothing
209+ stripGitHubPrefixes :: String -> Maybe String
210+ stripGitHubPrefixes = stripPrefixes [ "git://github.com/"
211+ , "https://github.com/"
215+ stripPrefixes :: [String] -> String -> Maybe String
216+ stripPrefixes prefixes str = msum $ (`stripPrefix` str) <$> prefixes
211 dropDotGit :: String -> String
218 dropDotGit :: String -> String
212 dropDotGit str
219 dropDotGit str
213 | ".git" `isSuffixOf` str = take (length str - 4) str
220 | ".git" `isSuffixOf` str = take (length str - 4) str
214 | otherwise = str
221 | otherwise = str
216− matchUrl :: String -> Maybe String
218− stripPrefix "git@github.com:" str <|> stripPrefix "git://github.com/" str
220readProcess' :: String -> [String] -> String -> PrepareM String
223readProcess' :: String -> [String] -> String -> PrepareM String
221readProcess' prog args stdin = do
224readProcess' prog args stdin = do
222 out <- liftIO (catch (Right <$> readProcess prog args stdin)
225 out <- liftIO (catch (Right <$> readProcess prog args stdin)