-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgreedy-url.js
30 lines (28 loc) · 886 Bytes
/
greedy-url.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const urlExp =
/https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}(\.[a-zA-Z0-9()]{1,6})?(?:[-a-zA-Z0-9()\[\],@:%_\+.~#?&\/=]*)/g;
function getURL(dataSet) {
let result = dataSet.match(urlExp);
return result;
}
function greedyQuery(dataSet) {
dataSet = getURL(dataSet);
let result = dataSet.filter((url) => {
return (
url.match(
/\?([-a-zA-Z0-9\[\],()@]*=[-a-zA-Z0-9\[\],()@]*&){2,255}([-a-zA-Z0-9\[\],()@]*=[-a-zA-Z0-9\[\],()@]*)/g
) !== null
);
});
return result;
}
function notSoGreedy(dataSet) {
dataSet = getURL(dataSet);
let result = dataSet.filter((url) => {
return (
url.match(
/\?([-a-zA-Z0-9\[\],()@%]*=[-a-zA-Z0-9\[\],()@%]*&){1,2}([-a-zA-Z0-9\[\],()@%]*=[-a-zA-Z0-9\[\],()@%]*)$/g
) !== null
);
});
return result;
}