Skip to content

Commit 4187c25

Browse files
committed
Bugfix for MISSING in strings with percantage sign
1 parent af74bd8 commit 4187c25

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

cmd/monako/main_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ func TestMainMonakoTest(t *testing.T) {
143143
assert.Len(t, doc.Find("body > main > aside.book-toc").Nodes, 1, "Asciidoc Page is missing aside.book-toc that is necessary for asciidoctor-fix")
144144
})
145145

146+
// Is tranformed to <a href="http://urlwith.quotes/My%!L(MISSING)inkWith%!W(MISSING)hitespace" class="bare">http://urlwith.quotes/My%!L(MISSING)inkWith%!W(MISSING)hitespace</a>
147+
t.Run("Check for Link with whitespaces", func(t *testing.T) {
148+
assert.Contains(t, content, "href=\"http://urlwith.quotes/My%20LinkWith%20Whitespace\"", "Does not contain rendered asciidoc with correct %20")
149+
})
150+
146151
})
147152

148153
t.Run("Check for RSS feed", func(t *testing.T) {

pkg/compose/file.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ MonakoGitLastCommitAuthor: %s
226226
MonakoGitLastCommitAuthorEmail: %s
227227
---
228228
229-
`+body,
229+
%s`,
230230
oldFrontmatter,
231231
file.parentOrigin.URL,
232232
file.RemotePath,
@@ -244,7 +244,9 @@ MonakoGitLastCommitAuthorEmail: %s
244244
// Resulting in no date format functions on the file
245245
file.Commit.Date.Format(time.RFC3339),
246246
file.Commit.Author.Name,
247-
file.Commit.Author.Email),
247+
file.Commit.Author.Email,
248+
body,
249+
),
248250
nil
249251

250252
}

pkg/compose/file_test.go

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package compose
22

3-
// run: MONAKO_TEST_REPO="$HOME/temp/monako-testrepos/monako-test" go test ./pkg/compose -run TestCommitInfo
3+
// run: MONAKO_TEST_REPO="$HOME/temp/monako-testrepos/monako-test" go test ./pkg/compose -run TestExpandFrontmatter
44

55
import (
66
"fmt"
77
"path/filepath"
88
"testing"
9+
"time"
910

1011
"github.com/stretchr/testify/assert"
1112
)
@@ -282,3 +283,36 @@ func TestCommitInfo(t *testing.T) {
282283
})
283284

284285
}
286+
287+
func TestExpandFrontmatter(t *testing.T) {
288+
289+
t.Run("Expand Frontmatter Simple", func(t *testing.T) {
290+
// t.Skip("not ready")
291+
})
292+
293+
t.Run("Expand Frontmatter with whitespace in URLs", func(t *testing.T) {
294+
file := &OriginFile{
295+
LocalPath: "localpath",
296+
RemotePath: "remotepath",
297+
parentOrigin: &Origin{Branch: "master",
298+
repo: nil,
299+
URL: "http://gitrepo.git",
300+
SourceDir: "sourcedir",
301+
TargetDir: "targetdir",
302+
},
303+
Commit: &OriginFileCommit{
304+
Hash: "abc",
305+
Author: OriginFileCommitter{
306+
Email: "mail@mail.com",
307+
Name: "commiter name"},
308+
Date: time.Now(),
309+
},
310+
}
311+
312+
result, err := file.ExpandFrontmatter("content with http://test.de/bla%20blub in link")
313+
assert.NoError(t, err)
314+
assert.Contains(t, result, "http://test.de/bla%20blub")
315+
316+
})
317+
318+
}

0 commit comments

Comments
 (0)