r57982 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57981‎ | r57982 | r57983 >
Date:17:57, 21 October 2009
Author:catrope
Status:deferred
Tags:
Comment:
EditToolbar: Use $wgUrlProtocols to determine if something is a URL
Modified paths:
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js
@@ -779,11 +779,14 @@
780780 init: function() {
781781 function isExternalLink( s ) {
782782 // The following things are considered to be external links:
783 - // * Starts with one or more letters followed by ://
 783+ // * Starts a URL protocol
784784 // * Starts with www.
785785 // * Ends with a . followed by two or more letters
786786 // * Contains a . followed by two or more letters followed by /
787 - return s.match( /(^[a-z]+:\/\/)|(^www\.)|([^.]\.[a-z]{2,}($|\/))/i );
 787+ if ( typeof arguments.callee.regex == 'undefined' )
 788+ // Cache the regex
 789+ arguments.callee.regex = new RegExp( "(^(" + urlprotocols + "))|(^www\\.)|([^.]\\.[a-z]{2,}($|\\/))", 'i');
 790+ return s.match( arguments.callee.regex );
788791 }
789792 // Updates the UI to show if the page title being inputed by the user exists or not
790793 function updateExistence() {
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php
@@ -19,7 +19,7 @@
2020 /* Configuration */
2121
2222 // Bump the version number every time you change any of the .css/.js files
23 -$wgEditToolbarStyleVersion = 60;
 23+$wgEditToolbarStyleVersion = 61;
2424
2525 // Set this to true to simply override the stock toolbar for everyone
2626 $wgEditToolbarGlobalEnable = false;

Follow-up revisions

RevisionCommit summaryAuthorDate
r58170Correcting bug #21293 introduced in r57982 - removing a trailing comma that w...adam22:48, 26 October 2009

Status & tagging log