Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 13, 09:15 UTC
replacer: working directory global placeholder (#5127)
Kévin Dunglas committed
Oct 7, 2022 at 11:54 UTC
b4e28af953aa02fb44f88c155956488b1f473348
2 files changed
+9
replacer.go
+4
@@ -308,6 +308,10 @@ func globalDefaultReplacements(key string) (any, bool) {
308
return string(filepath.Separator), true
309
case "system.os":
310
return runtime.GOOS, true
311
+ case "system.wd":
312
+ // OK if there is an error; just return empty string
313
+ wd, _ := os.Getwd()
314
+ return wd, true
315
case "system.arch":
316
return runtime.GOARCH, true
317
case "time.now":
replacer_test.go
+5
@@ -372,6 +372,7 @@ func TestReplacerNew(t *testing.T) {
372
} else {
373
// test if default global replacements are added as the first provider
374
hostname, _ := os.Hostname()
375
+ wd, _ := os.Getwd()
376
os.Setenv("CADDY_REPLACER_TEST", "envtest")
377
defer os.Setenv("CADDY_REPLACER_TEST", "")
378
@@ -395,6 +396,10 @@ func TestReplacerNew(t *testing.T) {
396
variable: "system.arch",
397
value: runtime.GOARCH,
398
},
399
+ {
400
+ variable: "system.wd",
401
+ value: wd,
402
+ },
403
{
404
variable: "env.CADDY_REPLACER_TEST",
405
value: "envtest",