From 917979c02a0134c4d939bcd3f740a96110dac600 Mon Sep 17 00:00:00 2001 From: Evert Pot Date: Thu, 2 Jan 2020 14:34:02 -0500 Subject: [PATCH 1/2] Update HAL browser to support more templated links formats. Specifically, the HAL browser will now support link expansions in the format: http://example/{?foo,bar} This is an alternative to: http://example/{?foo}{?bar} --- src/components/forms/templated-links.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/forms/templated-links.ts b/src/components/forms/templated-links.ts index 5c4eb9f..d12d404 100644 --- a/src/components/forms/templated-links.ts +++ b/src/components/forms/templated-links.ts @@ -36,17 +36,22 @@ export default function parseTemplatedLinks(links: Link[], options: SureOptions) // More formats might be added if they are requested. // This regex finds blocks like {?foo} - const reg = /{\?[A-Za-z]+}/g; + const reg = /{\?[A-Za-z,]+}/g; const matches = link.href.match(reg); if (matches) { for (const match of matches) { // Stripping off {? and } - fields.push({ - name: match.slice(2, -1), - value: '', - label: match.slice(2, -1), - }); + const fieldNames = match.slice(2, -1); + + // Splitting at ',' + for(const fieldName of fieldNames.split(',')) { + fields.push({ + name: fieldName, + value: '', + label: fieldName, + }); + } } } From 802ef98e7364295806f077bbbcd08144494d3e24 Mon Sep 17 00:00:00 2001 From: Evert Pot Date: Thu, 2 Jan 2020 15:19:55 -0500 Subject: [PATCH 2/2] Lint --- src/components/forms/templated-links.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/forms/templated-links.ts b/src/components/forms/templated-links.ts index d12d404..8331c97 100644 --- a/src/components/forms/templated-links.ts +++ b/src/components/forms/templated-links.ts @@ -45,7 +45,7 @@ export default function parseTemplatedLinks(links: Link[], options: SureOptions) const fieldNames = match.slice(2, -1); // Splitting at ',' - for(const fieldName of fieldNames.split(',')) { + for (const fieldName of fieldNames.split(',')) { fields.push({ name: fieldName, value: '',