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

feat: support escape slash in wikilinks #290

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion Marksman/Misc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ type String with
sb.ToString()

member this.EncodeForWiki() : string =
let replacement = [| "#", "%23"; "[", "%5B"; "]", "%5D"; "|", "%7C" |]
let replacement =
[| "#", "%23"; "[", "%5B"; "]", "%5D"; "|", "%7C"; "\\|", "%7C" |]

replacement
|> Array.fold (fun (sb: StringBuilder) -> sb.Replace) (StringBuilder(this))
Expand Down
4 changes: 2 additions & 2 deletions Tests/MiscTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ module StringExtensionsTests =

[<Fact>]
let encodeForWiki_2 () =
let original = "blah #blah [] () |"
let expected = "blah %23blah %5B%5D () %7C"
let original = "blah #blah [] () | \\|"
let expected = "blah %23blah %5B%5D () %7C %7C"
let actual = original.EncodeForWiki()
Assert.Equal(expected, actual)
Assert.Equal(original, actual.UrlDecode())
Expand Down
Loading