-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: bouk/staticfiles is deprecated #11654
Signed-off-by: Son Bui <[email protected]>
- Loading branch information
Showing
11 changed files
with
176 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,5 +65,3 @@ issues: | |
- sdks | ||
- ui | ||
- vendor | ||
exclude-files: | ||
- server/static/files.go |
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,95 @@ | ||
package static | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestReplaceBaseHRef(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
data string | ||
expected string | ||
replaceWith string | ||
}{ | ||
{ | ||
name: "non-root basepath", | ||
data: `<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Argo</title> | ||
<base href="/"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<meta name="robots" content="noindex"> | ||
<link rel="icon" type="image/png" href="assets/favicon/favicon-32x32.png" sizes="32x32"> | ||
<link rel="icon" type="image/png" href="assets/favicon/favicon-16x16.png" sizes="16x16"> | ||
<script defer="defer" src="main.js"></script> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
</body> | ||
</html>`, | ||
expected: `<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Argo</title> | ||
<base href="/path1/path2/path3/"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<meta name="robots" content="noindex"> | ||
<link rel="icon" type="image/png" href="assets/favicon/favicon-32x32.png" sizes="32x32"> | ||
<link rel="icon" type="image/png" href="assets/favicon/favicon-16x16.png" sizes="16x16"> | ||
<script defer="defer" src="main.js"></script> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
</body> | ||
</html>`, | ||
replaceWith: `<base href="/path1/path2/path3/">`, | ||
}, | ||
{ | ||
name: "root basepath", | ||
data: `<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Argo</title> | ||
<base href="/any/path/test/"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<meta name="robots" content="noindex"> | ||
<link rel="icon" type="image/png" href="assets/favicon/favicon-32x32.png" sizes="32x32"> | ||
<link rel="icon" type="image/png" href="assets/favicon/favicon-16x16.png" sizes="16x16"> | ||
<script defer="defer" src="main.js"></script> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
</body> | ||
</html>`, | ||
expected: `<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Argo</title> | ||
<base href="/"> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<meta name="robots" content="noindex"> | ||
<link rel="icon" type="image/png" href="assets/favicon/favicon-32x32.png" sizes="32x32"> | ||
<link rel="icon" type="image/png" href="assets/favicon/favicon-16x16.png" sizes="16x16"> | ||
<script defer="defer" src="main.js"></script> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
</body> | ||
</html>`, | ||
replaceWith: `<base href="/">`, | ||
}, | ||
} | ||
for _, testCase := range testCases { | ||
t.Run(testCase.name, func(t *testing.T) { | ||
result := replaceBaseHRef(testCase.data, testCase.replaceWith) | ||
assert.Equal(t, testCase.expected, result) | ||
}) | ||
} | ||
} |
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,10 @@ | ||
package ui | ||
|
||
import "embed" | ||
|
||
const EMBED_PATH = "dist/app" | ||
|
||
// Embedded contains embedded UI resources | ||
// | ||
//go:embed dist/app | ||
var Embedded embed.FS |