-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from darkweak/feat/chore/support-relative-paths
feat(chore): Support relative paths
- Loading branch information
Showing
9 changed files
with
162 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<esi:include src="http://invalid.do.main" alt=http://domain.com:9080/alt-esi-include/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<esi:include src="http://domain.com/chained-esi-include-1" alt=http://domain.com/alt-esi-include/> | ||
<esi:include src="http://domain.com:9080/chained-esi-include-1" alt=http://domain.com:9080/alt-esi-include/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package caddy_esi | ||
|
||
import ( | ||
"net/http" | ||
"os" | ||
"testing" | ||
|
||
"github.com/caddyserver/caddy/v2/caddytest" | ||
) | ||
|
||
const expectedOutput = `<html> | ||
<head> | ||
<title>Hello from domain.com:9080</title> | ||
</head> | ||
<body> | ||
<esi:include src="domain.com/not-interpreted"/> | ||
<h1>CHAINED 2</h1> | ||
<h1>ALTERNATE ESI INCLUDE</h1> | ||
</body> | ||
</html> | ||
` | ||
|
||
func loadCaddyfile() string { | ||
b, _ := os.ReadFile("./Caddyfile") | ||
return string(b) | ||
} | ||
|
||
func TestFullHTML(t *testing.T) { | ||
tester := caddytest.NewTester(t) | ||
tester.InitServer(loadCaddyfile(), "caddyfile") | ||
|
||
_, _ = tester.AssertGetResponse(`http://domain.com:9080/full.html`, http.StatusOK, expectedOutput) | ||
} | ||
|
||
func TestInclude(t *testing.T) { | ||
tester := caddytest.NewTester(t) | ||
tester.InitServer(loadCaddyfile(), "caddyfile") | ||
|
||
_, _ = tester.AssertGetResponse(`http://domain.com:9080/include`, http.StatusOK, "<h1>CHAINED 2</h1>") | ||
} | ||
|
||
func TestIncludeAlt(t *testing.T) { | ||
tester := caddytest.NewTester(t) | ||
tester.InitServer(loadCaddyfile(), "caddyfile") | ||
|
||
_, _ = tester.AssertGetResponse(`http://domain.com:9080/alt`, http.StatusOK, "<h1>ALTERNATE ESI INCLUDE</h1>") | ||
} | ||
|
||
func TestEscape(t *testing.T) { | ||
tester := caddytest.NewTester(t) | ||
tester.InitServer(loadCaddyfile(), "caddyfile") | ||
|
||
_, _ = tester.AssertGetResponse(`http://domain.com:9080/escape`, http.StatusOK, ` | ||
<p><esi:vars>Hello, $(HTTP_COOKIE{name})!</esi:vars></p> | ||
`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.