Merge pull request #128 from serokell/Sereja313/#126-make-ignoreRefs-required

[#126] Make `ignoreRefs` a required parameter
This commit is contained in:
Sereja313 2022-08-29 18:28:38 +10:00 committed by GitHub
commit bf81311e43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 8 additions and 9 deletions

View File

@ -25,6 +25,8 @@ Unreleased
+ Fix the issue of having the lowest level context duplicated, caused by the root's trailing path separator.
* [#31](https://github.com/serokell/xrefcheck/pull/88)
+ Handle the "429 too many requests" errors & attempt to eliminate them during verification.
* [#128](https://github.com/serokell/xrefcheck/pull/128)
+ Make `ignoreRefs` a required parameter.
0.2.1
==========

View File

@ -84,7 +84,7 @@ xrefcheck --help
If you want some external links to not be verified, you can use one of the following ways to ignore those links:
1. Add the regular expression that matches the ignoring link to the optional `ignoreRefs` parameter of your config file.
1. Add the regular expression that matches the ignoring link to the `ignoreRefs` parameter of your config file.
For example:
```yaml

View File

@ -55,7 +55,7 @@ data VerifyConfig = VerifyConfig
-- ^ Files which we pretend do exist.
, vcNotScanned :: [FilePath]
-- ^ Prefixes of files, references in which we should not analyze.
, vcIgnoreRefs :: Maybe [Regex]
, vcIgnoreRefs :: [Regex]
-- ^ Regular expressions that match external references we should not verify.
, vcCheckLocalhost :: Bool
-- ^ If True - we will check localhost links.

View File

@ -45,7 +45,6 @@ verification:
# POSIX extended regular expressions that match external references
# that have to be ignored (not verified).
# It is an optional parameter, so it can be omitted.
ignoreRefs: []
# Check localhost links.

View File

@ -434,7 +434,7 @@ checkExternalResource VerifyConfig{..} link
where
skipCheck = isIgnored || (not vcCheckLocalhost && isLocalLink)
where
isIgnored = maybe False (doesMatchAnyRegex link) vcIgnoreRefs
isIgnored = doesMatchAnyRegex link vcIgnoreRefs
isLocalLink = any (`T.isInfixOf` link) ["://localhost", "://127.0.0.1"]
doesMatchAnyRegex :: Text -> ([Regex] -> Bool)

View File

@ -77,11 +77,10 @@ spec = do
Just neWithRefLoc -> map (rLink . wrlReference) $ toList neWithRefLoc
Nothing -> []
linksToRegexs :: [Text] -> Maybe [Regex]
linksToRegexs :: [Text] -> [Regex]
linksToRegexs links =
let errOrRegexs = map (decodeEither' . encodeUtf8) links
maybeRegexs = map (either (error . show) Just) errOrRegexs
in sequence maybeRegexs
in map (either (error . show) id) errOrRegexs
setIgnoreRefs :: Maybe [Regex] -> Config -> Config
setIgnoreRefs :: [Regex] -> Config -> Config
setIgnoreRefs regexs = (cVerificationL . vcIgnoreRefsL) .~ regexs

View File

@ -36,7 +36,6 @@ verification:
# POSIX extended regular expressions that match external references
# that have to be ignored (not verified).
# It is an optional parameter, so it can be omitted.
ignoreRefs: []
# Check localhost links.