Skip to content

Commit

Permalink
fixed bug preventing external scripts config from being loaded via EN…
Browse files Browse the repository at this point in the history
…V variable
  • Loading branch information
albogdano committed Dec 6, 2023
1 parent 53d000b commit b05bf0f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/com/erudika/scoold/ScooldConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import static com.erudika.scoold.ScooldServer.SIGNINLINK;
import static com.erudika.scoold.ScooldServer.SIGNOUTLINK;
import com.typesafe.config.ConfigObject;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import javax.inject.Named;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
Expand Down Expand Up @@ -2581,13 +2581,17 @@ public String externalStyles() {
description = "A map of external JS scripts. These will be loaded after the main JS script. For example: "
+ "`scoold.external_scripts.script1 = \"alert('Hi')\"`")
public Map<String, Object> externalScripts() {
String prefix = "scoold_external_scripts_";
Map<String, Object> ext = new LinkedHashMap<>(System.getenv().keySet().stream().
filter(k -> k.startsWith(prefix)).collect(Collectors.
toMap(mk -> StringUtils.removeStart(mk, prefix), mv -> System.getenv(mv))));
if (getConfig().hasPath("external_scripts")) {
ConfigObject extScripts = getConfig().getObject("external_scripts");
if (extScripts != null && !extScripts.isEmpty()) {
return new LinkedHashMap<>(extScripts.unwrapped());
ext.putAll(extScripts.unwrapped());
}
}
return Collections.emptyMap();
return ext;
}

@Documented(position = 2410,
Expand Down

0 comments on commit b05bf0f

Please sign in to comment.