File tree 5 files changed +20
-15
lines changed 5 files changed +20
-15
lines changed Original file line number Diff line number Diff line change @@ -255,6 +255,14 @@ module.exports = (function () {
255
255
return s ;
256
256
} ;
257
257
258
+ /**
259
+ * Extracting the value of an attribute.
260
+ *
261
+ * @param {string } attribute - The input attribute string.
262
+ * @returns {string } The extracted attribute value.
263
+ */
264
+ const getOptionValue = ( attribute ) => attribute . slice ( attribute . indexOf ( '="' ) + 2 , - 1 ) ;
265
+
258
266
/**
259
267
* Parses include line
260
268
*
@@ -283,17 +291,8 @@ module.exports = (function () {
283
291
exclude = attribute . substring ( attribute . indexOf ( '=' ) + 1 ) ;
284
292
exclude = stripEndQuotes ( exclude ) ;
285
293
} else if ( attribute . startsWith ( INCLUDE_OPTION_MODIFIERS ) ) {
286
- // Find the index of the first occurrence of '="' and add 2 to get the start index of the value.
287
- const startIndex = attribute . indexOf ( '="' ) + 2 ;
288
- // Find the index of the last occurrence of '"' to get the end index of the value.
289
- const endIndex = attribute . lastIndexOf ( '"' ) ;
290
- if ( startIndex !== - 1 && endIndex !== - 1 ) {
291
- // If both start and end indexes are found, extract the value between the quotes.
292
- addModifiers = attribute . slice ( startIndex , endIndex ) ;
293
- } else {
294
- // If the quotes are not found, set 'addModifiers' to null.
295
- addModifiers = null ;
296
- }
294
+ // If value of the option is not specified, then it will be set to null.
295
+ addModifiers = getOptionValue ( attribute ) || null ;
297
296
}
298
297
}
299
298
Original file line number Diff line number Diff line change @@ -505,7 +505,7 @@ module.exports = (() => {
505
505
} else {
506
506
metadata = removeObsoleteFilters ( metadata ) ;
507
507
}
508
-
508
+ // #TODO: https://github.com/AdguardTeam/FiltersCompiler/issues/195
509
509
const filtersContent = JSON . stringify ( metadata , null , '\t' ) ;
510
510
511
511
fs . writeFileSync ( filtersFileJson , filtersContent , 'utf8' ) ;
Original file line number Diff line number Diff line change @@ -81,8 +81,10 @@ describe('Test builder', () => {
81
81
expect ( line . trim ( ) . endsWith ( '$image,script' ) ) . toBeTruthy ( ) ;
82
82
} ) ;
83
83
} ) ;
84
-
85
- it ( 'filter 8 test' , async ( ) => {
84
+ // Temporarily left at number eight, because under the number of its id (10) in filters.json
85
+ // stands above the Base filter and tests for the Base filter, checking the sequence - crashes
86
+ // #TODO: fix this
87
+ it ( 'filter 10 test' , async ( ) => {
86
88
// Read the content of the file and split it into lines
87
89
const filterContent = await readFile ( path . join ( filtersDir , 'filter_8_Modifiers' , 'filter.txt' ) ) ;
88
90
const filterLines = filterContent . split ( / \r ? \n / ) ;
@@ -91,7 +93,7 @@ describe('Test builder', () => {
91
93
// Get only rule lines without empty lines or comments
92
94
const ruleLines = filterLines . filter ( ( line ) => ! line . startsWith ( '!' ) && line . length > 0 ) ;
93
95
// Check that the number of lines in the file is equal to 10 (excluding comments)
94
- expect ( ruleLines . length ) . toEqual ( 10 ) ;
96
+ expect ( ruleLines . length ) . toEqual ( 15 ) ;
95
97
// Check that each line (excluding comments) contains '$'
96
98
ruleLines
97
99
. forEach ( ( line ) => {
Original file line number Diff line number Diff line change 6
6
a155e09a56.reuters.tv
7
7
albany.townsquarenewsletters.com
8
8
alerts.dmgt.com
9
+ ! comment
9
10
aremedia.e.aremedia.com.au
10
11
auto.scissorsscotch.com
Original file line number Diff line number Diff line change 1
1
! Homepage: http://adguard.com/filters.html#english
2
2
! License: http://creativecommons.org/licenses/by-sa/3.0/
3
3
!
4
+ !#if (adguard_app_mac)
5
+ @include ../cname_trackers.txt /stripComments /addModifiers="image"
6
+ !#endif
4
7
!#if (adguard_app_ios)
5
8
@include ../cname_trackers.txt /addModifiers="image,script"
6
9
!#endif
You can’t perform that action at this time.
0 commit comments