mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-11-30 03:54:12 +01:00
Print template strings in plain quotes unless they can't round-trip (#708)
This commit is contained in:
1 parent
6e7f23a778
commit
23d369d84e
6 files changed
+191
-19
No files matched your search
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Matches a template tag up to the first `]}`, the same way the Lezer grammar and the JSON
|
||||
* linter close a tag. Quoted arguments may contain spaces, so this can't stop at whitespace.
|
||||
*/
|
||||
const TEMPLATE_TAG_REGEX = /\$\{\[[\s\S]*?]}/g;
|
||||
|
||||
export function validateHttpHeader(v: string): boolean {
|
||||
if (v === "") {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Template strings are not allowed so we replace them with a valid example string
|
||||
const withoutTemplateStrings = v.replace(TEMPLATE_TAG_REGEX, "123");
|
||||
return withoutTemplateStrings.match(/^[a-zA-Z0-9-_]+$/) !== null;
|
||||
}
|
||||
Reference in new issue
Block a user