forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: replace deprecated
bouk/staticfiles
with native Go embed
. fixes
argoproj#11654 (argoproj#11707) Signed-off-by: Son Bui <[email protected]>
- Loading branch information
Showing
12 changed files
with
177 additions
and
90 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 |
---|---|---|
|
@@ -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) | ||
}) | ||
} | ||
} |
Oops, something went wrong.