@queue-it/fastly 2.0.0-beta.0 → 2.0.0-beta.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@queue-it/fastly",
3
- "version": "2.0.0-beta.0",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "Queue-it connector for Fastly",
5
5
  "main": "src/index.ts",
6
6
  "author": "devs@queue-it.com",
@@ -68,7 +68,13 @@ export class FastlyHttpRequest implements IHttpRequest {
68
68
  if (this.parsedCookieDic.size == 0) {
69
69
  this.parseCookies(this.getHeader('cookie'))
70
70
  }
71
- return this.parsedCookieDic.has(cookieKey) ? decodeURIComponent(this.parsedCookieDic.get(cookieKey)!) : '';
71
+ if (!this.parsedCookieDic.has(cookieKey)) return '';
72
+ const cookieVal = this.parsedCookieDic.get(cookieKey)!;
73
+ try {
74
+ return decodeURIComponent(cookieVal);
75
+ } catch {
76
+ return cookieVal;
77
+ }
72
78
  }
73
79
 
74
80
  getHeader(name: string): string {
@@ -33,7 +33,11 @@ export class Utils {
33
33
  }
34
34
 
35
35
  static decodeUrl(url: string): string {
36
- return decodeURIComponent(url);
36
+ try {
37
+ return decodeURIComponent(url);
38
+ } catch {
39
+ return url;
40
+ }
37
41
  }
38
42
 
39
43
  static generateSHA256Hash: (a: string, b: string) => string = (secretKey: string, stringToHash: string): string => "";
@@ -107,11 +111,15 @@ export class Utils {
107
111
  const regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');
108
112
  const results = regex.exec(url);
109
113
  if (results === null) return '';
110
- if (results.length < 3) {
114
+ if (results.length < 3 || results[2] === null || results[2] === undefined) {
111
115
  return '';
112
116
  }
113
117
 
114
- return decodeURIComponent(results[2].replaceAll('+', ' '));
118
+ try {
119
+ return decodeURIComponent(results[2].replaceAll('+', ' '));
120
+ } catch {
121
+ return results[2];
122
+ }
115
123
  }
116
124
 
117
125
  static removeQueueItToken(url: string): string {
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Queue-it
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.