File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 9393 _prioritiseMatchingFilename : function ( resultList , term ) {
9494 return resultList . sort ( function ( a , b ) {
9595 // use indexOf() in favour of startsWith() for browser compatibility
96- if ( a . title . indexOf ( 'File :' + term ) === 0 ) {
96+ if ( a . title . indexOf ( this . _getFileNamespace ( ) + ' :' + term ) === 0 ) {
9797 return - 1 ;
98- } else if ( b . title . indexOf ( 'File :' + term ) === 0 ) {
98+ } else if ( b . title . indexOf ( this . _getFileNamespace ( ) + ' :' + term ) === 0 ) {
9999 return 1 ;
100100 } else {
101101 return 0 ;
114114 _createMenuItemFromSuggestion : function ( suggestion , requestTerm ) {
115115 suggestion = suggestion . title ;
116116
117- var isFile = / ^ F i l e : / . test ( suggestion ) ;
117+ var isFile = this . _getFileNamespaceRegex ( ) . test ( suggestion ) ;
118118
119119 if ( isFile ) {
120- suggestion = suggestion . replace ( / ^ F i l e : / , '' ) ;
120+ suggestion = suggestion . replace ( this . _getFileNamespaceRegex ( ) , '' ) ;
121121 }
122122
123123 var label = util . highlightSubstring (
163163 return 'url("' + this . options . indexPhpUrl + '?title=Special:Filepath/'
164164 + encodeURIComponent ( fileName )
165165 + '&width=100&height=50")' ;
166+ } ,
167+
168+ /**
169+ * @private
170+ *
171+ * @returns {string }
172+ */
173+ _getFileNamespace : function ( ) {
174+ return mw . config . get ( 'wgFormattedNamespaces' ) [ 6 ] ;
175+ } ,
176+
177+ /**
178+ * @private
179+ *
180+ * @returns {RegExp }
181+ */
182+ _getFileNamespaceRegex : function ( ) {
183+ return new RegExp ( '^' + this . _getFileNamespace ( ) + ':' ) ;
166184 }
167185
168186 } ) ;
You can’t perform that action at this time.
0 commit comments