This repository was archived by the owner on Nov 15, 2017. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +27
-4
lines changed
Expand file tree Collapse file tree 1 file changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -33,11 +33,35 @@ var friendlyTypeNames = {
3333 '*' : '\u2217' ,
3434 'cookie' : 'cookie' ,
3535 'stylesheet' : 'css' ,
36+ 'css' : 'css' ,
3637 'image' : 'img' ,
3738 'object' : 'plugin' ,
39+ 'plugin' : 'plugin' ,
3840 'script' : 'script' ,
3941 'xmlhttprequest' : 'XHR' ,
42+ 'xhr' : 'XHR' ,
43+ 'XHR' : 'XHR' ,
4044 'sub_frame' : 'frame' ,
45+ 'frame' : 'frame' ,
46+ 'other' : 'other'
47+ } ;
48+
49+ var machineTypeNames = {
50+ '*' : '*' ,
51+ '\u2217' : '*' ,
52+ 'cookie' : 'cookie' ,
53+ 'stylesheet' : 'stylesheet' ,
54+ 'css' : 'stylesheet' ,
55+ 'image' : 'image' ,
56+ 'img' : 'image' ,
57+ 'object' : 'object' ,
58+ 'plugin' : 'object' ,
59+ 'script' : 'script' ,
60+ 'xmlhttprequest' : 'xmlhttprequest' ,
61+ 'xhr' : 'xmlhttprequest' ,
62+ 'XHR' : 'xmlhttprequest' ,
63+ 'sub_frame' : 'sub_frame' ,
64+ 'frame' : 'sub_frame' ,
4165 'other' : 'other'
4266} ;
4367
@@ -66,7 +90,7 @@ function renderRuleToRecipeString(rule) {
6690}
6791
6892function renderRecipeStringToRule ( recipe ) {
69- var parts = recipe . match ( / ^ ( [ a - z * _ ] + ) + ( [ - . : a - z 0 - 9 * ] + ) $ / ) ;
93+ var parts = recipe . match ( / ^ ( [ a - z * _ ] + ) + ( [ - . : a - z 0 - 9 * ] + ) $ / i ) ;
7094 if ( ! parts ) {
7195 return false ;
7296 }
@@ -76,11 +100,10 @@ function renderRecipeStringToRule(recipe) {
76100 return false ;
77101 }
78102 // Validate type
79- var type = parts [ 1 ] ;
80- if ( ! friendlyTypeNames [ parts [ 1 ] ] ) {
103+ if ( machineTypeNames . hasOwnProperty ( parts [ 1 ] ) === false ) {
81104 return false ;
82105 }
83- return type + '|' + hostname ;
106+ return machineTypeNames [ parts [ 1 ] ] + '|' + hostname ;
84107}
85108
86109/******************************************************************************/
You can’t perform that action at this time.
0 commit comments