Skip to content

Commit

Permalink
fix regex escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
wsbrunson committed Jun 18, 2024
1 parent 7888c61 commit ba1c088
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/meta.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,13 @@ export function unpackSDKMeta(sdkMeta?: string): SDKMeta {
// parse out a patch version, set version as latest
// if neither cases are true, leave version alone because
// it can be more than a semver version number ("min" for example)
if (/4\\.0\\.\\d{1,3}/.test(version)) {
//
// NOTE ABOUT REGEX
// The . in the regex technically need to be escaped but that breaks the
// regex in real browsers. Because we are writing JavaScript in a string, we
// need a double escape (\\.) which breaks the browser but works when using eval()
// a single escape works in the browser but breaks in the tests with eval()
if (/4.0.\\d{1,3}/.test(version)) {
var patchString = version?.split('.')?.pop()
if (!patchString) {
Expand Down

0 comments on commit ba1c088

Please sign in to comment.