query = $.param( params );
}
if ( query ) {
- url = title
- ? util.wikiScript() + '?title=' + util.wikiUrlencode( title ) + '&' + query
- : util.wikiScript() + '?' + query;
+ url = title ?
+ util.wikiScript() + '?title=' + util.wikiUrlencode( title ) + '&' + query :
+ util.wikiScript() + '?' + query;
} else {
- url = mw.config.get( 'wgArticlePath' ).replace( '$1', util.wikiUrlencode( title ) );
+ url = mw.config.get( 'wgArticlePath' )
+ .replace( '$1', util.wikiUrlencode( title ).replace( /\$/g, '$$$$' ) );
}
// Append the encoded fragment
* @return {Mixed} Parameter value or null.
*/
getParamValue: function ( param, url ) {
- if ( url === undefined ) {
- url = location.href;
- }
// Get last match, stop at hash
var re = new RegExp( '^[^#]*[&?]' + mw.RegExp.escape( param ) + '=([^&#]*)' ),
- m = re.exec( url );
+ m = re.exec( url !== undefined ? url : location.href );
+
if ( m ) {
// Beware that decodeURIComponent is not required to understand '+'
// by spec, as encodeURIComponent does not produce it.
// - atext : defined in RFC 5322 section 3.2.3
// - ldh-str : defined in RFC 1034 section 3.5
//
- // (see STD 68 / RFC 5234 http://tools.ietf.org/html/std68)
+ // (see STD 68 / RFC 5234 https://tools.ietf.org/html/std68)
// First, define the RFC 5322 'atext' which is pretty easy:
// atext = ALPHA / DIGIT / ; Printable US-ASCII
// "!" / "#" / ; characters not including
html5EmailRegexp = new RegExp(
// start of string
- '^'
- +
+ '^' +
// User part which is liberal :p
- '[' + rfc5322Atext + '\\.]+'
- +
+ '[' + rfc5322Atext + '\\.]+' +
// 'at'
- '@'
- +
+ '@' +
// Domain first part
- '[' + rfc1034LdhStr + ']+'
- +
+ '[' + rfc1034LdhStr + ']+' +
// Optional second part and following are separated by a dot
- '(?:\\.[' + rfc1034LdhStr + ']+)*'
- +
+ '(?:\\.[' + rfc1034LdhStr + ']+)*' +
// End of string
'$',
// RegExp is case insensitive
* @return {boolean}
*/
isIPv4Address: function ( address, allowBlock ) {
+ var block, RE_IP_BYTE, RE_IP_ADD;
+
if ( typeof address !== 'string' ) {
return false;
}
- var block = allowBlock ? '(?:\\/(?:3[0-2]|[12]?\\d))?' : '',
- RE_IP_BYTE = '(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|0?[0-9]?[0-9])',
- RE_IP_ADD = '(?:' + RE_IP_BYTE + '\\.){3}' + RE_IP_BYTE;
+ block = allowBlock ? '(?:\\/(?:3[0-2]|[12]?\\d))?' : '';
+ RE_IP_BYTE = '(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|0?[0-9]?[0-9])';
+ RE_IP_ADD = '(?:' + RE_IP_BYTE + '\\.){3}' + RE_IP_BYTE;
return ( new RegExp( '^' + RE_IP_ADD + block + '$' ).test( address ) );
},
* @return {boolean}
*/
isIPv6Address: function ( address, allowBlock ) {
+ var block, RE_IPV6_ADD;
+
if ( typeof address !== 'string' ) {
return false;
}
- var block = allowBlock ? '(?:\\/(?:12[0-8]|1[01][0-9]|[1-9]?\\d))?' : '',
- RE_IPV6_ADD =
- '(?:' + // starts with "::" (including "::")
- ':(?::|(?::' + '[0-9A-Fa-f]{1,4}' + '){1,7})' +
- '|' + // ends with "::" (except "::")
- '[0-9A-Fa-f]{1,4}' + '(?::' + '[0-9A-Fa-f]{1,4}' + '){0,6}::' +
- '|' + // contains no "::"
- '[0-9A-Fa-f]{1,4}' + '(?::' + '[0-9A-Fa-f]{1,4}' + '){7}' +
- ')';
+ block = allowBlock ? '(?:\\/(?:12[0-8]|1[01][0-9]|[1-9]?\\d))?' : '';
+ RE_IPV6_ADD =
+ '(?:' + // starts with "::" (including "::")
+ ':(?::|(?::' + '[0-9A-Fa-f]{1,4}' + '){1,7})' +
+ '|' + // ends with "::" (except "::")
+ '[0-9A-Fa-f]{1,4}' + '(?::' + '[0-9A-Fa-f]{1,4}' + '){0,6}::' +
+ '|' + // contains no "::"
+ '[0-9A-Fa-f]{1,4}' + '(?::' + '[0-9A-Fa-f]{1,4}' + '){7}' +
+ ')';
if ( new RegExp( '^' + RE_IPV6_ADD + block + '$' ).test( address ) ) {
return true;
RE_IPV6_ADD = '[0-9A-Fa-f]{1,4}' + '(?:::?' + '[0-9A-Fa-f]{1,4}' + '){1,6}';
return (
- new RegExp( '^' + RE_IPV6_ADD + block + '$' ).test( address )
- && /::/.test( address )
- && !/::.*::/.test( address )
+ new RegExp( '^' + RE_IPV6_ADD + block + '$' ).test( address ) &&
+ /::/.test( address ) &&
+ !/::.*::/.test( address )
);
},