diff options
| author | Kenny Grant <kennygrant@gmail.com> | 2016-12-18 07:24:58 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2017-02-18 06:35:36 +0000 |
| commit | 497b608faba2a9c450d03e2bca2ef005ea32b933 (patch) | |
| tree | a65269119309dbd5d40e6778ad9d210646e1d7db /src/go/doc/comment_test.go | |
| parent | a4a3d63dbeb57174ada4b2e5f0fa54c9ec83803b (diff) | |
| download | go-git-497b608faba2a9c450d03e2bca2ef005ea32b933.tar.gz | |
go/doc: allow : in godoc links
The emphasize function used a complex regexp to find URLs, which
truncated some types of URL and did not match others.
This has been simplified and adjusted to allow valid punctuation
like :: or ! in the path part and :[] in the host part.
Comments were added to clarify what this regexp allows.
The path part matches query and fragment also so document this.
Removed news, telnet, wais, and prospero protocols.
Tests were added for:
IPV6 URLs
URLs surrounded by brackets
URLs containing ::
URLs containing :;!- in the path
In order to allow punctuation and yet preserve current behaviour,
URLs are not permitted to end in .,:;?! to allow the use of
normal punctuation surrounding URLs in comments.
Fixes #18139
Change-Id: I38b2d7a85fe0d171e4bf4aac420f8c2d3ced8a2f
Reviewed-on: https://go-review.googlesource.com/37192
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/go/doc/comment_test.go')
| -rw-r--r-- | src/go/doc/comment_test.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/go/doc/comment_test.go b/src/go/doc/comment_test.go index 76dfbeac79..0523ab899e 100644 --- a/src/go/doc/comment_test.go +++ b/src/go/doc/comment_test.go @@ -150,6 +150,12 @@ func TestToText(t *testing.T) { var emphasizeTests = []struct { in, out string }{ + {"http://[::1]:8080/foo.txt", `<a href="http://[::1]:8080/foo.txt">http://[::1]:8080/foo.txt</a>`}, + {"before (https://www.google.com) after", `before (<a href="https://www.google.com">https://www.google.com</a>) after`}, + {"before https://www.google.com:30/x/y/z:b::c. After", `before <a href="https://www.google.com:30/x/y/z:b::c">https://www.google.com:30/x/y/z:b::c</a>. After`}, + {"http://www.google.com/path/:;!-/?query=%34b#093124", `<a href="http://www.google.com/path/:;!-/?query=%34b#093124">http://www.google.com/path/:;!-/?query=%34b#093124</a>`}, + {"http://www.google.com/path/:;!-/?query=%34bar#093124", `<a href="http://www.google.com/path/:;!-/?query=%34bar#093124">http://www.google.com/path/:;!-/?query=%34bar#093124</a>`}, + {"http://www.google.com/index.html! After", `<a href="http://www.google.com/index.html">http://www.google.com/index.html</a>! After`}, {"http://www.google.com/", `<a href="http://www.google.com/">http://www.google.com/</a>`}, {"https://www.google.com/", `<a href="https://www.google.com/">https://www.google.com/</a>`}, {"http://www.google.com/path.", `<a href="http://www.google.com/path">http://www.google.com/path</a>.`}, |
