opticedge-cloud-utils 1.1.2 → 1.1.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.
package/dist/regex.d.ts CHANGED
@@ -1 +1 @@
1
- export declare function escapeRegex(input: string): string;
1
+ export declare function escapeForRegex(input: string): string;
package/dist/regex.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.escapeRegex = escapeRegex;
4
- function escapeRegex(input) {
3
+ exports.escapeForRegex = escapeForRegex;
4
+ function escapeForRegex(input) {
5
5
  return input.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opticedge-cloud-utils",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Common utilities for cloud functions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/regex.ts CHANGED
@@ -1,3 +1,3 @@
1
- export function escapeRegex(input: string): string {
1
+ export function escapeForRegex(input: string): string {
2
2
  return input.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
3
3
  }
@@ -1,24 +1,24 @@
1
- import { escapeRegex } from '../src/regex'
1
+ import { escapeForRegex } from '../src/regex'
2
2
 
3
3
  describe('escapeRegex', () => {
4
4
  it('escapes regex special characters', () => {
5
5
  const input = 'Pikachu.$^*+?()[]{}|\\'
6
6
  const expected = 'Pikachu\\.\\$\\^\\*\\+\\?\\(\\)\\[\\]\\{\\}\\|\\\\'
7
- expect(escapeRegex(input)).toBe(expected)
7
+ expect(escapeForRegex(input)).toBe(expected)
8
8
  })
9
9
 
10
10
  it('returns same string if no special characters', () => {
11
11
  const input = 'Charmander123'
12
- expect(escapeRegex(input)).toBe('Charmander123')
12
+ expect(escapeForRegex(input)).toBe('Charmander123')
13
13
  })
14
14
 
15
15
  it('works with empty string', () => {
16
- expect(escapeRegex('')).toBe('')
16
+ expect(escapeForRegex('')).toBe('')
17
17
  })
18
18
 
19
19
  it('does not escape regular alphanumerics or spaces', () => {
20
20
  const input = 'Lt. Surge Pikachu'
21
21
  const expected = 'Lt\\. Surge Pikachu'
22
- expect(escapeRegex(input)).toBe(expected)
22
+ expect(escapeForRegex(input)).toBe(expected)
23
23
  })
24
24
  })