Ignore parameters with pre-filled JSON values
Summary: https://fb.workplace.com/groups/flippersupport/permalink/1513232162490770/ Apparently, some apps use JSONs as values for their params Reviewed By: lblasa Differential Revision: D41684474 fbshipit-source-id: 4ab19313ede06b226715a5c398728f0be7feddaf
This commit is contained in:
committed by
Facebook GitHub Bot
parent
904e530f74
commit
73e7298525
@@ -60,12 +60,20 @@ export const replaceRequiredParametersWithValues = (
|
||||
};
|
||||
|
||||
export const getRequiredParameters = (uri: string) => {
|
||||
const parameterRegExp = /{[^?]*?}/g;
|
||||
// Add = to the matching group to filter out stringified JSON parameters
|
||||
const parameterRegExp = /={[^?]*?}/g;
|
||||
const matches: Array<string> = [];
|
||||
let match = parameterRegExp.exec(uri);
|
||||
while (match != null) {
|
||||
if (match[0]) {
|
||||
matches.push(match[0]);
|
||||
// Remove = from the match
|
||||
const target = match[0].substring(1);
|
||||
try {
|
||||
// If the value could be parsed asa valid JSON, ignore it
|
||||
JSON.parse(target);
|
||||
} catch {
|
||||
matches.push(target);
|
||||
}
|
||||
}
|
||||
match = parameterRegExp.exec(uri);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user