зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1593837 - Filter WS messages with regular expressions. r=Honza
Differential Revision: https://phabricator.services.mozilla.com/D64409 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
2bb1e352b2
Коммит
4f5b9e90d2
|
@ -22,17 +22,40 @@ const getDisplayedFrames = createSelector(
|
|||
return framesArray;
|
||||
}
|
||||
|
||||
const filter = searchFilter(frameFilterText);
|
||||
|
||||
// If frame payload is > 10,000 characters long, we check the LongStringActor payload string
|
||||
return framesArray.filter(
|
||||
frame =>
|
||||
(frame.payload.initial
|
||||
? frame.payload.initial.includes(frameFilterText)
|
||||
: frame.payload.includes(frameFilterText)) &&
|
||||
? filter(frame.payload.initial)
|
||||
: filter(frame.payload)) &&
|
||||
(frameFilterType === "all" || frameFilterType === frame.type)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
function searchFilter(frameFilterText) {
|
||||
let regex;
|
||||
if (looksLikeRegex(frameFilterText)) {
|
||||
try {
|
||||
regex = regexFromText(frameFilterText);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
return regex
|
||||
? payload => regex.test(payload)
|
||||
: payload => payload.includes(frameFilterText);
|
||||
}
|
||||
|
||||
function looksLikeRegex(text) {
|
||||
return text.startsWith("/") && text.endsWith("/") && text.length > 2;
|
||||
}
|
||||
|
||||
function regexFromText(text) {
|
||||
return new RegExp(text.slice(1, -1), "im");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the selected frame is visible.
|
||||
* If the selected frame is not visible, the SplitBox component
|
||||
|
|
Загрузка…
Ссылка в новой задаче