@dbx-tools/shared-core 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/string.ts +13 -1
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },
25
- "version": "0.3.1",
25
+ "version": "0.3.3",
26
26
  "types": "index.ts",
27
27
  "type": "module",
28
28
  "exports": {
package/src/string.ts CHANGED
@@ -33,7 +33,11 @@ type ResolvedIdentifierOptions = Required<
33
33
  IdentifierOptions & Pick<TokenizeOptions, "lowerCase" | "capitalize">
34
34
  >;
35
35
 
36
- const TOKENIZE_CAMEL_CASE_REGEXP = /[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;
36
+ // A leading `v`/`V` immediately followed by digits (a version marker like
37
+ // `v2`) is kept as ONE token instead of splitting into `v` + `2`; it leads the
38
+ // alternation so it wins over the generic letter / digit runs. Everything else
39
+ // is the usual camelCase word / number / all-caps-acronym split.
40
+ const TOKENIZE_CAMEL_CASE_REGEXP = /[vV][0-9]+|[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;
37
41
  const TOKENIZE_NON_ALPHANUMERIC_REGEXP = /[a-zA-Z0-9]+/g;
38
42
  const TOKENIZE_OVERRIDES: ((token: string, options: TokenizeOptions) => string)[] = [
39
43
  (token, options) => {
@@ -42,6 +46,14 @@ const TOKENIZE_OVERRIDES: ((token: string, options: TokenizeOptions) => string)[
42
46
  }
43
47
  return token;
44
48
  },
49
+ // Version marker `v2` -> `V2` when capitalizing (the leading `v` uppercases,
50
+ // the digits stay), so it reads as one unit rather than "V 2".
51
+ (token, options) => {
52
+ if (options.capitalize && /^v[0-9]+$/.test(token)) {
53
+ return `V${token.slice(1)}`;
54
+ }
55
+ return token;
56
+ },
45
57
  ];
46
58
  const URI_REGEXP = /^([a-zA-Z][a-zA-Z0-9+.-]*)?:\/\/([^\s/?#][^\s]*)?$/;
47
59
  const EMAIL_REGEXP = /^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+)@([a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+)$/;