diff --git a/desktop/plugins/public/navigation/__tests__/testURI.node.tsx b/desktop/plugins/public/navigation/__tests__/testURI.node.tsx index 8bac54e30..78eb83048 100644 --- a/desktop/plugins/public/navigation/__tests__/testURI.node.tsx +++ b/desktop/plugins/public/navigation/__tests__/testURI.node.tsx @@ -28,6 +28,14 @@ test('parse required numeric parameters from uri', () => { expect(getRequiredParameters(testURI)).toEqual(expectedResult); }); +// https://fb.workplace.com/groups/flippersupport/permalink/1513232162490770/ +test('ignore params with JSON values', () => { + const testURI = + 'fb://test_uri/?parameter1={"test":"value"}¶meter2="{\\"test\\":\\"value\\"}"'; + const expectedResult: string[] = []; + expect(getRequiredParameters(testURI)).toEqual(expectedResult); +}); + test('replace required parameters with values', () => { const testURI = 'fb://test_uri/?parameter1={parameter1}¶meter2={parameter2}'; diff --git a/desktop/plugins/public/navigation/util/uri.tsx b/desktop/plugins/public/navigation/util/uri.tsx index 69b9996bd..fae2610f3 100644 --- a/desktop/plugins/public/navigation/util/uri.tsx +++ b/desktop/plugins/public/navigation/util/uri.tsx @@ -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 = []; 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); }