summaryrefslogtreecommitdiff
path: root/lib/Properties.hs
diff options
context:
space:
mode:
authorjonny2021-12-29 00:32:52 +0100
committerstuebinm2022-03-19 19:23:08 +0100
commitc9c472a36b0db933771a6feb24709e78cae1822b (patch)
tree177ffd90c6b83084529524143964d3a1f300dbdf /lib/Properties.hs
parent5b1fe362589b9ce6aa36e2df6fda4b3165bcdb32 (diff)
use url package for parsing of urls
Diffstat (limited to 'lib/Properties.hs')
-rw-r--r--lib/Properties.hs12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Properties.hs b/lib/Properties.hs
index 31823e6..f346f7f 100644
--- a/lib/Properties.hs
+++ b/lib/Properties.hs
@@ -45,7 +45,7 @@ import LintWriter (LintWriter, adjust, askContext,
import Paths (PathResult (..), RelPath (..), getExtension,
isOldStyle, parsePath)
import Types (Dep (Link, Local, LocalMap, MapLink))
-import Uris (SubstError (..), applySubsts, parseUri)
+import Uris (SubstError (..), applySubsts, parseUri, extractDomain)
@@ -143,7 +143,7 @@ checkMapProperty p@(Property name _) = case name of
-- scripts can be used by one map
_ | T.toLower name == "script" ->
unwrapString p $ \str ->
- unless (("https://static.rc3.world/scripts" `isPrefixOf` str) &&
+ unless ((checkIsRc3Url str) &&
(not $ "/../" `isInfixOf` str) &&
(not $ "%" `isInfixOf` str) &&
(not $ "@" `isInfixOf` str))
@@ -344,6 +344,12 @@ checkObjectGroupProperty (Property name _) = case name of
\not the object layer."
_ -> warn $ "unknown property " <> prettyprint name <> " for objectgroup layers"
+checkIsRc3Url :: Text -> Bool
+checkIsRc3Url text= case extractDomain text of
+ Nothing -> False
+ Just domain -> do
+ domain == "https://static.rc3.world"
+
-- | Checks a single (custom) property of a "normal" tile layer
checkTileThing :: (HasProperties a, HasName a, HasData a) => Bool -> Property -> LintWriter a
@@ -500,7 +506,7 @@ checkTileThing removeExits p@(Property name _value) = case name of
-> do
properties <- askContext <&> getProperties
unless (all (\(Property name value) -> case value of
- StrProp str -> name /= "openWebsite" || "https://static.rc3.world/" `isPrefixOf` str
+ StrProp str -> name /= "openWebsite" || checkIsRc3Url str
_ -> True
) properties)
$ complain "\"openWebsiteAllowApi\" can only be used with websites hosted \