From b1dcbc9edd964b9d0cab6c26db4d502840011ac4 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Tue, 16 Nov 2021 19:51:58 +0100 Subject: add adjustment: add prefix for openWebsite --- config.json | 3 ++- lib/LintConfig.hs | 1 + lib/Properties.hs | 7 +++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config.json b/config.json index 87298f0..f52e1a2 100644 --- a/config.json +++ b/config.json @@ -3,5 +3,6 @@ "ScriptInject":null, "AllowScripts":true, "MaxWarnLevel":"Suggestion", - "DontCopyAssets":true + "DontCopyAssets":true, + "LinkPrefix":"https://exit.rc3.world?link=" } diff --git a/lib/LintConfig.hs b/lib/LintConfig.hs index 5596005..5c1ae20 100644 --- a/lib/LintConfig.hs +++ b/lib/LintConfig.hs @@ -40,6 +40,7 @@ data LintConfig f = LintConfig -- ^ Don't copy map assets (mostly useful for development) , configAllowScripts :: HKD f Bool -- ^ Allow defining custom scripts in maps + , configLinkPrefix :: HKD f Text } deriving (Generic) type LintConfig' = LintConfig Identity diff --git a/lib/Properties.hs b/lib/Properties.hs index 50fec53..90aa3ad 100644 --- a/lib/Properties.hs +++ b/lib/Properties.hs @@ -153,7 +153,10 @@ checkLayerProperty p@(Property name _value) = case name of uselessEmptyLayer suggestProperty $ Property "openWebsiteTrigger" (StrProp "onaction") unwrapLink p $ \link -> if "https://" `isPrefixOf` link - then dependsOn $ Link link + then do + dependsOn $ Link link + prefix <- lintConfig configLinkPrefix + setProperty "openWebsite" (prefix <> link) else unwrapPath link (dependsOn . Local) "openWebsiteTrigger" -> do isString p @@ -173,7 +176,7 @@ checkLayerProperty p@(Property name _value) = case name of "allowApi" -> isForbidden "exitUrl" -> do forbidEmptyLayer - unwrapLink p $ \link -> if "https://" `isPrefixOf` link + unwrapLink p $ \link -> if "/" `isPrefixOf` link then dependsOn $ MapLink link else unwrapPath link (dependsOn . LocalMap) "startLayer" -> do -- cgit v1.2.3