Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
/
Help
What's new
2
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Projects
Groups
Snippets
Sign up now
Login
Sign in / Register
Toggle navigation
Menu
Open sidebar
eyeo
adblockplus
abc
adblockpluscore
Commits
ee3158dc
Commit
ee3158dc
authored
Sep 13, 2018
by
Sebastian Noack
Browse files
Issue 6923 - Simplify parsing of metadata
parent
25519781
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/synchronizer.js
View file @
ee3158dc
...
...
@@ -160,18 +160,15 @@ class Synchronizer
};
for
(
let
i
=
1
;
i
<
lines
.
length
;
i
++
)
{
let
match
=
/^
\s
*!
\s
*
(
?:(\w
+
)\s
*:
\s
*
(
.*
)
|
\S)
/
.
exec
(
lines
[
i
]);
let
match
=
/^
\s
*!
\s
*
(
.*
?
)\s
*:
\s
*
(
.*
)
/
.
exec
(
lines
[
i
]);
if
(
!
match
)
break
;
if
(
typeof
match
[
1
]
!=
"
undefined
"
)
let
keyword
=
match
[
1
].
toLowerCase
();
if
(
params
.
hasOwnProperty
(
keyword
))
{
let
keyword
=
match
[
1
].
toLowerCase
();
if
(
params
.
hasOwnProperty
(
keyword
))
{
params
[
keyword
]
=
match
[
2
];
lines
.
splice
(
i
--
,
1
);
}
params
[
keyword
]
=
match
[
2
];
lines
.
splice
(
i
--
,
1
);
}
}
...
...
test/synchronizer.js
View file @
ee3158dc
...
...
@@ -259,7 +259,7 @@ for (let currentTest of [
this
.
registerHandler
(
"
/subscription
"
,
metadata
=>
{
requests
.
push
(
this
.
getTimeOffset
());
return
[
Cr
.
NS_OK
,
200
,
"
[Adblock]
\n
!
foo
\n
!
Expires:
"
+
currentTest
.
expiration
+
"
\n
bar
"
];
return
[
Cr
.
NS_OK
,
200
,
"
[Adblock]
\n
!Expires:
"
+
currentTest
.
expiration
+
"
\n
bar
"
];
});
this
.
randomResult
=
currentTest
.
randomResult
;
...
...
@@ -319,7 +319,7 @@ exports.testRedirects = function(test)
this
.
registerHandler
(
"
/subscription
"
,
metadata
=>
{
return
[
Cr
.
NS_OK
,
200
,
"
[Adblock]
\n
!
foo
\n
!
Redirect: http://example.com/redirected
\n
bar
"
];
return
[
Cr
.
NS_OK
,
200
,
"
[Adblock]
\n
!Redirect: http://example.com/redirected
\n
bar
"
];
});
let
requests
;
...
...
@@ -335,7 +335,7 @@ exports.testRedirects = function(test)
this
.
registerHandler
(
"
/redirected
"
,
metadata
=>
{
requests
.
push
(
this
.
getTimeOffset
());
return
[
Cr
.
NS_OK
,
200
,
"
[Adblock]
\n
!
foo
\n
!
Expires: 8 hours
\n
bar
"
];
return
[
Cr
.
NS_OK
,
200
,
"
[Adblock]
\n
! Expires: 8 hours
\n
bar
"
];
});
resetSubscription
(
subscription
);
...
...
@@ -347,7 +347,7 @@ exports.testRedirects = function(test)
this
.
registerHandler
(
"
/redirected
"
,
metadata
=>
{
return
[
Cr
.
NS_OK
,
200
,
"
[Adblock]
\n
!
foo
\n
!
Redirect: http://example.com/subscription
\n
bar
"
];
return
[
Cr
.
NS_OK
,
200
,
"
[Adblock]
\n
!Redirect: http://example.com/subscription
\n
bar
"
];
});
subscription
=
Subscription
.
fromURL
(
"
http://example.com/subscription
"
);
...
...
Erik Vold
@erikvold
mentioned in merge request
!2 (closed)
·
Oct 31, 2018
mentioned in merge request
!2 (closed)
mentioned in merge request !2
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment