Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(parser): support encoded spaces in link URL #420

Merged
merged 1 commit into from
Sep 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions pkg/parser/link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ next lines`
})

It("relative link with all valid characters", func() {
source := `a link to link:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~:/?#@!$&;=()*+,-_.[as expected]`
source := `a link to link:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~:/?#@!$&;=()*+,-_.%[as expected]`
expected := types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: []types.InlineElements{
Expand All @@ -508,7 +508,7 @@ next lines`
types.InlineLink{
Location: types.Location{
types.StringElement{
Content: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~:/?#@!$&;=()*+,-_.",
Content: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~:/?#@!$&;=()*+,-_.%",
},
},
Attributes: types.ElementAttributes{
Expand All @@ -525,6 +525,37 @@ next lines`
Expect(source).To(EqualDocumentBlock(expected))
})

It("relative link with encoded space", func() {
source := `Test 1: link:/test/a b[with space]
Test 2: link:/test/a%20b[with encoded space]`
expected := types.Paragraph{
Attributes: types.ElementAttributes{},
Lines: []types.InlineElements{
{
types.StringElement{Content: "Test 1: link:/test/a b[with space]"},
},
{
types.StringElement{Content: "Test 2: "},
types.InlineLink{
Location: types.Location{
types.StringElement{
Content: "/test/a%20b",
},
},
Attributes: types.ElementAttributes{
types.AttrInlineLinkText: types.InlineElements{
types.StringElement{
Content: "with encoded space",
},
},
},
},
},
},
}
Expect(source).To(EqualDocumentBlock(expected))
})

Context("text attribute with comma", func() {

It("relative link only with text having comma", func() {
Expand Down
Loading