swc/bundler/tests/.cache/deno/2b9aa922c0505f3cae5a1babf57f87feb67c278e.ts
강동윤 bbaf619f63
fix(bundler): Fix bugs (#1437)
swc_bundler:
 - [x] Fix wrapped esms. (denoland/deno#9307)
 - [x] Make test secure.
2021-03-02 17:33:03 +09:00

41 lines
1015 B
TypeScript

// Loaded from https://deno.land/x/segno@v1.1.0/lib/validations/isRgbColor.ts
// @ts-ignore allowing typedoc to build
import { assertString } from '../helpers/assertString.ts';
/**
* @ignore
*/
const rgbColor = /^rgb\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){2}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\)$/;
/**
* @ignore
*/
const rgbaColor = /^rgba\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)$/;
/**
* @ignore
*/
const rgbColorPercent = /^rgb\((([0-9]%|[1-9][0-9]%|100%),){2}([0-9]%|[1-9][0-9]%|100%)\)/;
/**
* @ignore
*/
const rgbaColorPercent = /^rgba\((([0-9]%|[1-9][0-9]%|100%),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)/;
export const isRgbColor = (str: string, includePercentValues = true) => {
assertString(str);
if (!includePercentValues) {
return rgbColor.test(str) || rgbaColor.test(str);
}
return (
rgbColor.test(str) ||
rgbaColor.test(str) ||
rgbColorPercent.test(str) ||
rgbaColorPercent.test(str)
);
};