1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Add regex to enhance dsnIsValid

Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
This commit is contained in:
Hung-Han (Henry) Chen 2021-07-07 09:53:35 +03:00
parent e9a9f44b83
commit 86f05e11e3
No known key found for this signature in database
GPG Key ID: 54B44603D251B788

View File

@ -72,6 +72,10 @@ export const supportUrl = "https://docs.k8slens.dev/latest/support/" as string;
export const appSemVer = new SemVer(packageInfo.version); export const appSemVer = new SemVer(packageInfo.version);
export const docsUrl = `https://docs.k8slens.dev/main/` as string; export const docsUrl = `https://docs.k8slens.dev/main/` as string;
export const dsn = packageInfo.config?.sentryDsn; // Regular expression used to parse a Sentry Dsn.
export const dsnIsValid = isValidURL(dsn); // from https://github.com/getsentry/sentry-javascript/blob/f624f442fd76bf655de6def9fa4d7631735ebba0/packages/utils/src/dsn.ts#L6
const DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/;
export const dsn = packageInfo.config?.sentryDsn;
export const dsnIsValid = isValidURL(dsn) && DSN_REGEX.exec(dsn);