linkify_test.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. // Copyright 2008 The Closure Library Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS-IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. goog.provide('goog.string.linkifyTest');
  15. goog.setTestOnly('goog.string.linkifyTest');
  16. goog.require('goog.dom');
  17. goog.require('goog.dom.TagName');
  18. goog.require('goog.dom.safe');
  19. goog.require('goog.html.SafeHtml');
  20. goog.require('goog.string');
  21. goog.require('goog.string.linkify');
  22. goog.require('goog.testing.dom');
  23. goog.require('goog.testing.jsunit');
  24. var div = goog.dom.createElement(goog.dom.TagName.DIV);
  25. function assertLinkify(comment, input, expected, opt_preserveNewlines) {
  26. assertEquals(
  27. comment, expected,
  28. goog.html.SafeHtml.unwrap(
  29. goog.string.linkify.linkifyPlainTextAsHtml(
  30. input, {rel: '', target: ''}, opt_preserveNewlines)));
  31. }
  32. function testContainsNoLink() {
  33. assertLinkify(
  34. 'Text does not contain any links', 'Text with no links in it.',
  35. 'Text with no links in it.');
  36. }
  37. function testContainsALink() {
  38. assertLinkify(
  39. 'Text only contains a link', 'http://www.google.com/',
  40. '<a href="http://www.google.com/">http://www.google.com/<\/a>');
  41. }
  42. function testStartsWithALink() {
  43. assertLinkify(
  44. 'Text starts with a link',
  45. 'http://www.google.com/ is a well known search engine',
  46. '<a href="http://www.google.com/">http://www.google.com/<\/a>' +
  47. ' is a well known search engine');
  48. }
  49. function testEndsWithALink() {
  50. assertLinkify(
  51. 'Text ends with a link',
  52. 'Look at this search engine: http://www.google.com/',
  53. 'Look at this search engine: ' +
  54. '<a href="http://www.google.com/">http://www.google.com/<\/a>');
  55. }
  56. function testContainsOnlyEmail() {
  57. assertLinkify(
  58. 'Text only contains an email address', 'bolinfest@google.com',
  59. '<a href="mailto:bolinfest@google.com">bolinfest@google.com<\/a>');
  60. }
  61. function testStartsWithAnEmail() {
  62. assertLinkify(
  63. 'Text starts with an email address',
  64. 'bolinfest@google.com wrote this test.',
  65. '<a href="mailto:bolinfest@google.com">bolinfest@google.com<\/a>' +
  66. ' wrote this test.');
  67. }
  68. function testEndsWithAnEmail() {
  69. assertLinkify(
  70. 'Text ends with an email address',
  71. 'This test was written by bolinfest@google.com.',
  72. 'This test was written by ' +
  73. '<a href="mailto:bolinfest@google.com">bolinfest@google.com<\/a>.');
  74. }
  75. function testUrlWithPortNumber() {
  76. assertLinkify(
  77. 'URL with a port number', 'http://www.google.com:80/',
  78. '<a href="http://www.google.com:80/">http://www.google.com:80/<\/a>');
  79. }
  80. function testUrlWithUserPasswordAndPortNumber() {
  81. assertLinkify(
  82. 'URL with a user, a password and a port number',
  83. 'http://lascap:p4ssw0rd@google.com:80/s?q=a&hl=en',
  84. '<a href="http://lascap:p4ssw0rd@google.com:80/s?q=a&amp;hl=en">' +
  85. 'http://lascap:p4ssw0rd@google.com:80/s?q=a&amp;hl=en<\/a>');
  86. }
  87. function testUrlWithUnderscore() {
  88. assertLinkify(
  89. 'URL with an underscore', 'http://www_foo.google.com/',
  90. '<a href="http://www_foo.google.com/">http://www_foo.google.com/<\/a>');
  91. }
  92. function testInternalUrlWithoutDomain() {
  93. assertLinkify(
  94. 'Internal URL without a proper domain', 'http://tracker/1068594',
  95. '<a href="http://tracker/1068594">http://tracker/1068594<\/a>');
  96. }
  97. function testInternalUrlOneChar() {
  98. assertLinkify(
  99. 'Internal URL with a one char domain', 'http://b',
  100. '<a href="http://b">http://b<\/a>');
  101. }
  102. function testSecureInternalUrlWithoutDomain() {
  103. assertLinkify(
  104. 'Secure Internal URL without a proper domain', 'https://review/6594805',
  105. '<a href="https://review/6594805">https://review/6594805<\/a>');
  106. }
  107. function testTwoUrls() {
  108. assertLinkify(
  109. 'Text with two URLs in it',
  110. 'I use both http://www.google.com and http://yahoo.com, don\'t you?',
  111. 'I use both <a href="http://www.google.com">http://www.google.com<\/a> ' +
  112. 'and <a href="http://yahoo.com">http://yahoo.com<\/a>, ' +
  113. goog.string.htmlEscape('don\'t you?'));
  114. }
  115. function testGetParams() {
  116. assertLinkify(
  117. 'URL with GET params', 'http://google.com/?a=b&c=d&e=f',
  118. '<a href="http://google.com/?a=b&amp;c=d&amp;e=f">' +
  119. 'http://google.com/?a=b&amp;c=d&amp;e=f<\/a>');
  120. }
  121. function testGoogleCache() {
  122. assertLinkify(
  123. 'Google search result from cache',
  124. 'http://66.102.7.104/search?q=cache:I4LoMT6euUUJ:' +
  125. 'www.google.com/intl/en/help/features.html+google+cache&hl=en',
  126. '<a href="http://66.102.7.104/search?q=cache:I4LoMT6euUUJ:' +
  127. 'www.google.com/intl/en/help/features.html+google+cache&amp;hl=en">' +
  128. 'http://66.102.7.104/search?q=cache:I4LoMT6euUUJ:' +
  129. 'www.google.com/intl/en/help/features.html+google+cache&amp;hl=en' +
  130. '<\/a>');
  131. }
  132. function testUrlWithoutHttp() {
  133. assertLinkify(
  134. 'URL without http protocol',
  135. 'It\'s faster to type www.google.com without the http:// in front.',
  136. goog.string.htmlEscape('It\'s faster to type ') +
  137. '<a href="http://www.google.com">www.google.com' +
  138. '<\/a> without the http:// in front.');
  139. }
  140. function testUrlWithCapitalsWithoutHttp() {
  141. assertLinkify(
  142. 'URL with capital letters without http protocol',
  143. 'It\'s faster to type Www.google.com without the http:// in front.',
  144. goog.string.htmlEscape('It\'s faster to type ') +
  145. '<a href="http://Www.google.com">Www.google.com' +
  146. '<\/a> without the http:// in front.');
  147. }
  148. function testUrlHashBang() {
  149. assertLinkify(
  150. 'URL with #!', 'Another test URL: ' +
  151. 'https://www.google.com/testurls/#!/page',
  152. 'Another test URL: ' +
  153. '<a href="https://www.google.com/testurls/#!/page">' +
  154. 'https://www.google.com/testurls/#!/page<\/a>');
  155. }
  156. function testTextLooksLikeUrlWithoutHttp() {
  157. assertLinkify(
  158. 'Text looks like an url but is not', 'This showww.is just great: www.is',
  159. 'This showww.is just great: <a href="http://www.is">www.is<\/a>');
  160. }
  161. function testEmailWithSubdomain() {
  162. assertLinkify(
  163. 'Email with a subdomain', 'Send mail to bolinfest@groups.google.com.',
  164. 'Send mail to <a href="mailto:bolinfest@groups.google.com">' +
  165. 'bolinfest@groups.google.com<\/a>.');
  166. }
  167. function testEmailWithHyphen() {
  168. assertLinkify(
  169. 'Email with a hyphen in the domain name',
  170. 'Send mail to bolinfest@google-groups.com.',
  171. 'Send mail to <a href="mailto:bolinfest@google-groups.com">' +
  172. 'bolinfest@google-groups.com<\/a>.');
  173. }
  174. function testEmailUsernameWithSpecialChars() {
  175. assertLinkify(
  176. 'Email with a hyphen, period, and + in the user name',
  177. 'Send mail to bolin-fest+for.um@google.com',
  178. 'Send mail to <a href="mailto:bolin-fest+for.um@google.com">' +
  179. 'bolin-fest+for.um@google.com<\/a>');
  180. assertLinkify(
  181. 'Email with all special characters in the user name',
  182. 'Send mail to muad\'dib!#$%&\*/=?^_`{|}~@google.com', 'Send mail to ' +
  183. '<a href="mailto:muad&#39;dib!#$%&amp;\*/=?^_`{|}~@google.com">' +
  184. 'muad&#39;dib!#$%&amp;\*/=?^_`{|}~@google.com<\/a>');
  185. }
  186. function testEmailWithUnderscoreInvalid() {
  187. assertLinkify(
  188. 'Email with an underscore in the domain name, which is invalid',
  189. 'Do not email bolinfest@google_groups.com.',
  190. 'Do not email bolinfest@google_groups.com.');
  191. }
  192. function testUrlNotHttp() {
  193. assertLinkify(
  194. 'Url using unusual scheme',
  195. 'Looking for some goodies: ftp://ftp.google.com/goodstuff/',
  196. 'Looking for some goodies: ' +
  197. '<a href="ftp://ftp.google.com/goodstuff/">' +
  198. 'ftp://ftp.google.com/goodstuff/<\/a>');
  199. }
  200. function testJsInjection() {
  201. assertLinkify(
  202. 'Text includes some javascript',
  203. 'Welcome in hell <script>alert(\'this is hell\')<\/script>',
  204. goog.string.htmlEscape(
  205. 'Welcome in hell <script>alert(\'this is hell\')<\/script>'));
  206. }
  207. function testJsInjectionDotIsBlind() {
  208. assertLinkify(
  209. 'Javascript injection using regex . blindness to newline chars',
  210. '<script>malicious_code()<\/script>\nVery nice url: www.google.com',
  211. '&lt;script&gt;malicious_code()&lt;/script&gt;\nVery nice url: ' +
  212. '<a href="http://www.google.com">www.google.com<\/a>');
  213. }
  214. function testJsInjectionWithUnicodeLineReturn() {
  215. assertLinkify(
  216. 'Javascript injection using regex . blindness to newline chars with a ' +
  217. 'unicode newline character.',
  218. '<script>malicious_code()<\/script>\u2029Vanilla text',
  219. '&lt;script&gt;malicious_code()&lt;/script&gt;\u2029Vanilla text');
  220. }
  221. function testJsInjectionWithIgnorableNonTagChar() {
  222. assertLinkify(
  223. 'Angle brackets are normalized even when followed by an ignorable ' +
  224. 'non-tag character.',
  225. '<\u0000img onerror=alert(1337) src=\n>',
  226. '&lt;&#0;img onerror=alert(1337) src=\n&gt;');
  227. }
  228. function testJsInjectionWithTextarea() {
  229. assertLinkify(
  230. 'Putting the result in a textarea can\'t cause other textarea text to ' +
  231. 'be treated as tag content.',
  232. '</textarea', '&lt;/textarea');
  233. }
  234. function testJsInjectionWithNewlineConversion() {
  235. assertLinkify(
  236. 'Any newline conversion and whitespace normalization won\'t cause tag ' +
  237. 'parts to be recombined.',
  238. '<<br>script<br>>alert(1337)<<br>/<br>script<br>>',
  239. '&lt;&lt;br&gt;script&lt;br&gt;&gt;alert(1337)&lt;&lt;br&gt;/&lt;' +
  240. 'br&gt;script&lt;br&gt;&gt;');
  241. }
  242. function testNoProtocolBlacklisting() {
  243. assertLinkify(
  244. 'No protocol blacklisting.',
  245. 'Click: jscript:alert%281337%29\nClick: JSscript:alert%281337%29\n' +
  246. 'Click: VBscript:alert%281337%29\nClick: Script:alert%281337%29\n' +
  247. 'Click: flavascript:alert%281337%29',
  248. 'Click: jscript:alert%281337%29\nClick: JSscript:alert%281337%29\n' +
  249. 'Click: VBscript:alert%281337%29\nClick: Script:alert%281337%29\n' +
  250. 'Click: flavascript:alert%281337%29');
  251. }
  252. function testProtocolWhitelistingEffective() {
  253. assertLinkify(
  254. 'Protocol whitelisting is effective.',
  255. 'Click httpscript:alert%281337%29\nClick mailtoscript:alert%281337%29\n' +
  256. 'Click j\u00A0avascript:alert%281337%29\n' +
  257. 'Click \u00A0javascript:alert%281337%29',
  258. 'Click httpscript:alert%281337%29\nClick mailtoscript:alert%281337%29\n' +
  259. 'Click j\u00A0avascript:alert%281337%29\n' +
  260. 'Click \u00A0javascript:alert%281337%29');
  261. }
  262. function testLinkifyNoOptions() {
  263. goog.dom.safe.setInnerHtml(div,
  264. goog.string.linkify.linkifyPlainTextAsHtml('http://www.google.com'));
  265. goog.testing.dom.assertHtmlContentsMatch(
  266. '<a href="http://www.google.com" target="_blank" rel="nofollow">' +
  267. 'http://www.google.com<\/a>',
  268. div, true /* opt_strictAttributes */);
  269. }
  270. function testLinkifyOptionsNoAttributes() {
  271. goog.dom.safe.setInnerHtml(div, goog.string.linkify.linkifyPlainTextAsHtml(
  272. 'The link for www.google.com is located somewhere in ' +
  273. 'https://www.google.fr/?hl=en, you should find it easily.',
  274. {rel: '', target: ''}));
  275. goog.testing.dom.assertHtmlContentsMatch(
  276. 'The link for <a href="http://www.google.com">www.google.com<\/a> is ' +
  277. 'located somewhere in ' +
  278. '<a href="https://www.google.fr/?hl=en">https://www.google.fr/?hl=en' +
  279. '<\/a>, you should find it easily.',
  280. div, true /* opt_strictAttributes */);
  281. }
  282. function testLinkifyOptionsClassName() {
  283. goog.dom.safe.setInnerHtml(div, goog.string.linkify.linkifyPlainTextAsHtml(
  284. 'Attribute with <class> name www.w3c.org.', {'class': 'link-added'}));
  285. goog.testing.dom.assertHtmlContentsMatch(
  286. 'Attribute with &lt;class&gt; name <a href="http://www.w3c.org" ' +
  287. 'target="_blank" rel="nofollow" class="link-added">www.w3c.org<\/a>.',
  288. div, true /* opt_strictAttributes */);
  289. }
  290. function testFindFirstUrlNoScheme() {
  291. assertEquals(
  292. 'www.google.com', goog.string.linkify.findFirstUrl('www.google.com'));
  293. }
  294. function testFindFirstUrlNoSchemeUppercase() {
  295. assertEquals(
  296. 'WWW.GOOGLE.COM', goog.string.linkify.findFirstUrl('WWW.GOOGLE.COM'));
  297. }
  298. function testFindFirstUrlNoSchemeMixedcase() {
  299. assertEquals(
  300. 'WwW.GoOgLe.CoM', goog.string.linkify.findFirstUrl('WwW.GoOgLe.CoM'));
  301. }
  302. function testFindFirstUrlNoSchemeWithText() {
  303. assertEquals(
  304. 'www.google.com',
  305. goog.string.linkify.findFirstUrl('prefix www.google.com something'));
  306. }
  307. function testFindFirstUrlScheme() {
  308. assertEquals(
  309. 'http://www.google.com',
  310. goog.string.linkify.findFirstUrl('http://www.google.com'));
  311. }
  312. function testFindFirstUrlSchemeUppercase() {
  313. assertEquals(
  314. 'HTTP://WWW.GOOGLE.COM',
  315. goog.string.linkify.findFirstUrl('HTTP://WWW.GOOGLE.COM'));
  316. }
  317. function testFindFirstUrlSchemeMixedcase() {
  318. assertEquals(
  319. 'HtTp://WwW.gOoGlE.cOm',
  320. goog.string.linkify.findFirstUrl('HtTp://WwW.gOoGlE.cOm'));
  321. }
  322. function testFindFirstUrlSchemeWithText() {
  323. assertEquals(
  324. 'http://www.google.com', goog.string.linkify.findFirstUrl(
  325. 'prefix http://www.google.com something'));
  326. }
  327. function testFindFirstUrlNoUrl() {
  328. assertEquals(
  329. '', goog.string.linkify.findFirstUrl(
  330. 'ygvtfr676 5v68fk uygbt85F^&%^&I%FVvc .'));
  331. }
  332. function testFindFirstEmailNoScheme() {
  333. assertEquals(
  334. 'fake@google.com', goog.string.linkify.findFirstEmail('fake@google.com'));
  335. }
  336. function testFindFirstEmailNoSchemeUppercase() {
  337. assertEquals(
  338. 'FAKE@GOOGLE.COM', goog.string.linkify.findFirstEmail('FAKE@GOOGLE.COM'));
  339. }
  340. function testFindFirstEmailNoSchemeMixedcase() {
  341. assertEquals(
  342. 'fAkE@gOoGlE.cOm', goog.string.linkify.findFirstEmail('fAkE@gOoGlE.cOm'));
  343. }
  344. function testFindFirstEmailNoSchemeWithText() {
  345. assertEquals(
  346. 'fake@google.com',
  347. goog.string.linkify.findFirstEmail('prefix fake@google.com something'));
  348. }
  349. function testFindFirstEmailScheme() {
  350. assertEquals(
  351. 'mailto:fake@google.com',
  352. goog.string.linkify.findFirstEmail('mailto:fake@google.com'));
  353. }
  354. function testFindFirstEmailSchemeUppercase() {
  355. assertEquals(
  356. 'MAILTO:FAKE@GOOGLE.COM',
  357. goog.string.linkify.findFirstEmail('MAILTO:FAKE@GOOGLE.COM'));
  358. }
  359. function testFindFirstEmailSchemeMixedcase() {
  360. assertEquals(
  361. 'MaIlTo:FaKe@GoOgLe.CoM',
  362. goog.string.linkify.findFirstEmail('MaIlTo:FaKe@GoOgLe.CoM'));
  363. }
  364. function testFindFirstEmailSchemeWithText() {
  365. assertEquals(
  366. 'mailto:fake@google.com', goog.string.linkify.findFirstEmail(
  367. 'prefix mailto:fake@google.com something'));
  368. }
  369. function testFindFirstEmailNoEmail() {
  370. assertEquals(
  371. '', goog.string.linkify.findFirstEmail(
  372. 'ygvtfr676 5v68fk uygbt85F^&%^&I%FVvc .'));
  373. }
  374. function testContainsPunctuation_parens() {
  375. assertLinkify(
  376. 'Link contains parens, but does not end with them',
  377. 'www.google.com/abc(v1).html',
  378. '<a href="http://www.google.com/abc(v1).html">' +
  379. 'www.google.com/abc(v1).html<\/a>');
  380. }
  381. function testEndsWithPunctuation() {
  382. assertLinkify(
  383. 'Link ends with punctuation',
  384. 'Have you seen www.google.com? It\'s awesome.',
  385. 'Have you seen <a href="http://www.google.com">www.google.com<\/a>?' +
  386. goog.string.htmlEscape(' It\'s awesome.'));
  387. }
  388. function testEndsWithPunctuation_closeParen() {
  389. assertLinkify(
  390. 'Link inside parentheses', '(For more info see www.googl.com)',
  391. '(For more info see <a href="http://www.googl.com">www.googl.com<\/a>)');
  392. assertLinkify(
  393. 'Parentheses inside link',
  394. 'http://en.wikipedia.org/wiki/Titanic_(1997_film)',
  395. '<a href="http://en.wikipedia.org/wiki/Titanic_(1997_film)">' +
  396. 'http://en.wikipedia.org/wiki/Titanic_(1997_film)<\/a>');
  397. }
  398. function testEndsWithPunctuation_openParen() {
  399. assertLinkify(
  400. 'Link followed by open parenthesis', 'www.google.com(',
  401. '<a href="http://www.google.com(">www.google.com(<\/a>');
  402. }
  403. function testEndsWithPunctuation_angles() {
  404. assertLinkify(
  405. 'Link inside angled brackets',
  406. 'Here is a bibliography entry <http://www.google.com/>',
  407. 'Here is a bibliography entry &lt;<a href="http://www.google.com/">' +
  408. 'http://www.google.com/<\/a>&gt;');
  409. }
  410. function testEndsWithPunctuation_curlies() {
  411. assertLinkify(
  412. 'Link inside curly brackets', '{http://www.google.com/}',
  413. '{<a href="http://www.google.com/">' +
  414. 'http://www.google.com/<\/a>}');
  415. }
  416. function testEndsWithPunctuation_closingPairThenSingle() {
  417. assertLinkify(
  418. 'Link followed by closing punctuation pair then singular punctuation',
  419. 'Here is a bibliography entry <http://www.google.com/>, PTAL.',
  420. 'Here is a bibliography entry &lt;<a href="http://www.google.com/">' +
  421. 'http://www.google.com/<\/a>&gt;, PTAL.');
  422. }
  423. function testEndsWithPunctuation_ellipses() {
  424. assertLinkify(
  425. 'Link followed by three dots', 'just look it up on www.google.com...',
  426. 'just look it up on <a href="http://www.google.com">www.google.com' +
  427. '<\/a>...');
  428. }
  429. function testBracketsInUrl() {
  430. assertLinkify(
  431. 'Link containing brackets',
  432. 'before http://google.com/details?answer[0]=42 after',
  433. 'before <a href="http://google.com/details?answer[0]=42">' +
  434. 'http://google.com/details?answer[0]=42<\/a> after');
  435. }
  436. function testUrlWithExclamation() {
  437. assertLinkify(
  438. 'URL with exclamation points', 'This is awesome www.google.com!',
  439. 'This is awesome <a href="http://www.google.com">www.google.com<\/a>!');
  440. }
  441. function testSpecialCharactersInUrl() {
  442. assertLinkify(
  443. 'Link with characters that are neither reserved nor unreserved as per' +
  444. 'RFC 3986 but that are recognized by other Google properties.',
  445. 'https://www.google.com/?q=\`{|}recognized',
  446. '<a href="https://www.google.com/?q=\`{|}recognized">' +
  447. 'https://www.google.com/?q=\`{|}recognized<\/a>');
  448. }
  449. function testUsuallyUnrecognizedCharactersAreNotInUrl() {
  450. assertLinkify(
  451. 'Link with characters that are neither reserved nor unreserved as per' +
  452. 'RFC 3986 and which are not recognized by other Google properties.',
  453. 'https://www.google.com/?q=<^>"',
  454. '<a href="https://www.google.com/?q=">' +
  455. 'https://www.google.com/?q=<\/a>&lt;^&gt;&quot;');
  456. }
  457. function testIpv6Url() {
  458. assertLinkify(
  459. 'IPv6 URL', 'http://[::FFFF:129.144.52.38]:80/index.html',
  460. '<a href="http://[::FFFF:129.144.52.38]:80/index.html">' +
  461. 'http://[::FFFF:129.144.52.38]:80/index.html<\/a>');
  462. }
  463. function testPreserveNewlines() {
  464. assertLinkify(
  465. 'Preserving newlines', 'Example:\nhttp://www.google.com/',
  466. 'Example:<br>' +
  467. '<a href="http://www.google.com/">http://www.google.com/<\/a>',
  468. /* preserveNewlines */ true);
  469. assertLinkify(
  470. 'Preserving newlines with no links', 'Line 1\nLine 2', 'Line 1<br>Line 2',
  471. /* preserveNewlines */ true);
  472. }