check for a colon and slashes after http

This commit is contained in:
Greg Weber 2014-04-25 07:54:04 -07:00
parent 9fa5a23597
commit c5df0b0bf4

View File

@ -60,12 +60,12 @@ checkForImage n@("background-image") v = parseBackgroundImage n v
checkForImage n v = (n, Left v) checkForImage n v = (n, Left v)
parseBackgroundImage :: T.Text -> T.Text -> EithUrl parseBackgroundImage :: T.Text -> T.Text -> EithUrl
parseBackgroundImage n v = case P.parseOnly parseUrl v of parseBackgroundImage n v = (n, case P.parseOnly parseUrl v of
Left _ -> (n, Left v) -- Can't parse url Left _ -> Left v -- Can't parse url
Right url Right url ->
| "http" `T.isPrefixOf` url -> (n, Left v) if any (`T.isPrefixOf` url) ["http://", "https://", "/"]
| "/" `T.isPrefixOf` url -> (n, Left v) then Left v
| otherwise -> (n, Right $ UrlReference url) else Right $ UrlReference url)
parseCssWith :: (T.Text -> T.Text -> EithUrl) -> T.Text -> Either String Css parseCssWith :: (T.Text -> T.Text -> EithUrl) -> T.Text -> Either String Css
parseCssWith urlParser contents = parseCssWith urlParser contents =