|
@ -33,6 +33,8 @@ |
|
|
|
|
|
|
|
|
;(function(root) { |
|
|
;(function(root) { |
|
|
|
|
|
|
|
|
|
|
|
'use strict'; |
|
|
|
|
|
|
|
|
/******************************************************************************/ |
|
|
/******************************************************************************/ |
|
|
|
|
|
|
|
|
var exceptions = {}; |
|
|
var exceptions = {}; |
|
@ -45,6 +47,8 @@ var selfieMagic = 'iscjsfsaolnm'; |
|
|
var cutoffLength = 256; |
|
|
var cutoffLength = 256; |
|
|
var mustPunycode = /[^a-z0-9.-]/; |
|
|
var mustPunycode = /[^a-z0-9.-]/; |
|
|
|
|
|
|
|
|
|
|
|
var onChangedListeners = []; |
|
|
|
|
|
|
|
|
/******************************************************************************/ |
|
|
/******************************************************************************/ |
|
|
|
|
|
|
|
|
// In the context of this code, a domain is defined as:
|
|
|
// In the context of this code, a domain is defined as:
|
|
@ -234,6 +238,8 @@ function parse(text, toAscii) { |
|
|
} |
|
|
} |
|
|
crystallize(exceptions); |
|
|
crystallize(exceptions); |
|
|
crystallize(rules); |
|
|
crystallize(rules); |
|
|
|
|
|
|
|
|
|
|
|
callListeners(onChangedListeners); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/******************************************************************************/ |
|
|
/******************************************************************************/ |
|
@ -302,11 +308,47 @@ function fromSelfie(selfie) { |
|
|
} |
|
|
} |
|
|
rules = selfie.rules; |
|
|
rules = selfie.rules; |
|
|
exceptions = selfie.exceptions; |
|
|
exceptions = selfie.exceptions; |
|
|
|
|
|
callListeners(onChangedListeners); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/******************************************************************************/ |
|
|
/******************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
var addListener = function(listeners, callback) { |
|
|
|
|
|
if ( typeof callback !== 'function' ) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if ( listeners.indexOf(callback) === -1 ) { |
|
|
|
|
|
listeners.push(callback); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var removeListener = function(listeners, callback) { |
|
|
|
|
|
var pos = listeners.indexOf(callback); |
|
|
|
|
|
if ( pos !== -1 ) { |
|
|
|
|
|
listeners.splice(pos, 1); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var callListeners = function(listeners) { |
|
|
|
|
|
for ( var i = 0; i < listeners.length; i++ ) { |
|
|
|
|
|
listeners[i](); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
var onChanged = { |
|
|
|
|
|
addListener: function(callback) { |
|
|
|
|
|
addListener(onChangedListeners, callback); |
|
|
|
|
|
}, |
|
|
|
|
|
removeListener: function(callback) { |
|
|
|
|
|
removeListener(onChangedListeners, callback); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/ |
|
|
|
|
|
|
|
|
// Public API
|
|
|
// Public API
|
|
|
|
|
|
|
|
|
root = root || window; |
|
|
root = root || window; |
|
@ -317,7 +359,8 @@ root.publicSuffixList = { |
|
|
'getDomain': getDomain, |
|
|
'getDomain': getDomain, |
|
|
'getPublicSuffix': getPublicSuffix, |
|
|
'getPublicSuffix': getPublicSuffix, |
|
|
'toSelfie': toSelfie, |
|
|
'toSelfie': toSelfie, |
|
|
'fromSelfie': fromSelfie |
|
|
|
|
|
|
|
|
'fromSelfie': fromSelfie, |
|
|
|
|
|
'onChanged': onChanged |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/******************************************************************************/ |
|
|
/******************************************************************************/ |
|
|