Skip to content

Commit

Permalink
Merge pull request #56 from curveball/multiple-query-expansions
Browse files Browse the repository at this point in the history
Update HAL browser to support more templated links formats.
  • Loading branch information
evert authored Jan 2, 2020
2 parents 36f1fd2 + 802ef98 commit 149c9d3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/components/forms/templated-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}
}
}

Expand Down

0 comments on commit 149c9d3

Please sign in to comment.