User:Js/urldecoder.js: Difference between revisions

Content deleted Content added
Migration: mw.util.updateTooltipAccessKeys( $nodes ) → $nodes.updateTooltipAccessKeys() (see phab:rMW16c5d8801e465abd4d6ce7f44a516500a10bcb0d for details)
the secure server no longer exists
Line 82:
 
var httpRegExp = '((?:https?:)?\\/\\/[^\\]\\[\\n\\r<>" ]+)' // any chars except []<>" and \n and spaces
var localPrefix = WMPrefixes( unSecure( mw.config.get( 'wgServer' ).replace(/^\/\//,'http://') + mw.config.get( 'wgScript' ) ) )
var oldText, newText, isBeforeCursor, colonNS
 
Line 175:
 
var decodingFailed //need to skip some strange percent-encoded URIs
url = unSecure(url)
 
//percent-decoding
Line 320 ⟶ 319:
return [proj, lang]
 
}
 
 
 
function unSecure(url){
var mm = /https:\/\/secure\.wikimedia\.org\/(\w+)\/(\w+)\/([^\]\|\n\r ]+)/i.exec( url )
if( !mm) return url
var ___domain = mm[1].toLowerCase(), sub = mm[2].toLowerCase()
 
if( ! wmDomainM[___domain] ) return url //___domain not recognized
if( ___domain == 'wikipedia' ) //handle some special cases
switch( sub ){
case 'mediawiki': sub = 'www'; ___domain = 'mediawiki'; break
case 'foundation': sub = ''; ___domain = 'wikimediafoundation'; break
case 'sources': sub = ''; ___domain = 'wikisource'; break
default:
if( wmSubDomains.test(sub) ) ___domain = 'wikimedia' // .../wikipedia/meta -> meta.wikimedia.org
//otherwise: consider it language: .../wikipedia/en
}
return 'https://' + (sub ? sub + '.' : '') + ___domain + '.org/' + mm[3]
}