HomePhabricator

Avoid breaking full phabricator URLs
b68924b2979bUnpublished

Authored by thiemowmde on Dec 3 2015, 11:56 AM.

Unpublished Commit · Learn More

Not On Permanent Ref: This commit is not an ancestor of any permanent ref.

Description

Avoid breaking full phabricator URLs

This is an alternative to I20edf8e.

This patch does two things. If you think I should split this into two
patches, please tell me which one will be merged first.

  1. The negative lookahead (?!["<]) avoids the detection of ticket ids

in links. For example, the two ticket numbers in
<a href="https://phabricator.wikimedia.org/T1">T1</a> will not be
detected any more. Note that ECMAScript does support lookaheads, but
does not support lookbehinds.

  1. The additional (#\d+)? allows to link comments in tickets.

Note that I did not actually test this in Gerrit. Instead I wrote
this for testing:

<pre>
<script>
var match = "\\bT(\\d+)(#\\d+)?\\b(?![#\"<])",
link = "https://phabricator.wikimedia.org/T$1$2",
regex = new RegExp( match, 'g' ),
text = 'T1\n'

		+ 'T2#2\n'
		+ '<a href="http://T3">T3</a>\n'
		+ '<a href="http://T4#4">T4</a>';

document.write( text
.replace( regex, '<a href="' + link + '">T$1</a>' )
.replace( /</g, '&lt;' ) );
</script>

Bug: T75997
Bug: T76459
Change-Id: I2f06f93b6f7b42815c3594fd6902b078ea5a020e

Details

Committed
PaladoxJul 28 2016, 12:04 PM
Parents
rOPUPf47c30c891c5: statsd_proxy: fix config template
Branches
Unknown
Tags
Unknown
References
refs/changes/63/256663/9
ChangeId
I2f06f93b6f7b42815c3594fd6902b078ea5a020e