Commit 0659dea9 authored by Mark Stenglein's avatar Mark Stenglein

Parameter: isXName & isQuotedString: refactoring

This commit refactors the `isXName` and `isQuotedString` static methods
to avoid unneeded usage of single use varables for tracking the
pass/fail status.
Signed-off-by: Mark Stenglein's avatarMark Stenglein <mark@stengle.in>
parent 88d4aa71
Pipeline #1182 passed with stages
in 51 seconds
......@@ -223,10 +223,8 @@ export default class Parameter implements ICalElement {
* TODO: Implement this!
*/
public static isXName(input: string): boolean {
if (!(input.substring(0, 2) === "X-")) {
return false;
}
return /^[a-zA-Z0-9-]+$/.test(input);
return input.substring(0, 2) === "X-" &&
/^[a-zA-Z0-9-]+$/.test(input);
}
/**
......@@ -275,15 +273,9 @@ export default class Parameter implements ICalElement {
* @returns boolean If the input is a valid `quoted-string`
*/
public static isQuotedString(test: string): boolean {
let result: boolean = false;
if (
test.charAt(0) === "\"" &&
test.charAt(test.length - 1) === "\"" &&
Parameter.isQSafeChar(test.substring(1, test.length - 1))
) {
result = true;
}
return result;
return (test.charAt(0) === "\"" &&
test.charAt(test.length - 1) === "\"" &&
Parameter.isQSafeChar(test.substring(1, test.length - 1)));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment