@windstream/react-shared-components 0.2.23 → 0.2.25

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.
@@ -16,6 +16,7 @@ export const FindKinetic: React.FC<FindKineticProps> = ({
16
16
  title,
17
17
  color = "dark",
18
18
  maxWidth = true,
19
+ addTrailingSlash = false,
19
20
  }) => {
20
21
  const bgColorClasses: Record<ThemeKey, string> = {
21
22
  blue: "bg-[#07B2E2]",
@@ -25,12 +26,22 @@ export const FindKinetic: React.FC<FindKineticProps> = ({
25
26
  white: "bg-white",
26
27
  navy: "bg-[#00002D]",
27
28
  };
28
- const normalizedLocalPathPrefix = localPathPrefix
29
- ? `/${localPathPrefix.replace(/^\/+|\/+$/g, "")}`
29
+ // Trim leading/trailing slashes without a regex to avoid ReDoS on long
30
+ // runs of "/" (CodeQL: polynomial regular expression on uncontrolled data).
31
+ const trimSlashes = (value: string) => {
32
+ let start = 0;
33
+ let end = value.length;
34
+ while (start < end && value.charCodeAt(start) === 47 /* "/" */) start += 1;
35
+ while (end > start && value.charCodeAt(end - 1) === 47 /* "/" */) end -= 1;
36
+ return value.slice(start, end);
37
+ };
38
+ const cleanedLocalPathPrefix = trimSlashes(localPathPrefix ?? "");
39
+ const normalizedLocalPathPrefix = cleanedLocalPathPrefix
40
+ ? `/${cleanedLocalPathPrefix}`
30
41
  : "";
31
42
 
32
43
  const getLocationHref = (code: string) =>
33
- `${normalizedLocalPathPrefix}/${code.toLowerCase()}`;
44
+ `${normalizedLocalPathPrefix}/${code.toLowerCase()}${addTrailingSlash ? "/" : ""}`;
34
45
 
35
46
  return (
36
47
  <div
@@ -120,16 +131,21 @@ export const FindKinetic: React.FC<FindKineticProps> = ({
120
131
  key={`item-list-3-${index}`}
121
132
  className={`${image ? "" : "w-[172px]"}`}
122
133
  >
123
- <Link href={getLocationHref(item.code)} className="label1">
134
+ <Link
135
+ href={getLocationHref(item.code)}
136
+ className="label1"
137
+ >
124
138
  {item.name}
125
139
  </Link>
126
140
  </li>
127
- ) : <li key={`empty-3-${index}`} aria-hidden="true" />
141
+ ) : (
142
+ <li key={`empty-3-${index}`} aria-hidden="true" />
143
+ )
128
144
  );
129
145
  })()}
130
146
  </ul>
131
147
  {!image && (
132
- <ul className="hidden xl:grid xl:grid-cols-4 gap-x-20 gap-y-5">
148
+ <ul className="hidden gap-x-20 gap-y-5 xl:grid xl:grid-cols-4">
133
149
  {(() => {
134
150
  const sortedList = [...list].sort((a, b) =>
135
151
  a.name.localeCompare(b.name)
@@ -145,12 +161,20 @@ export const FindKinetic: React.FC<FindKineticProps> = ({
145
161
  }
146
162
  return rearranged.map((item, index: number) =>
147
163
  item ? (
148
- <li key={`item-list-4-${index}`} className="w-[172px]">
149
- <Link href={getLocationHref(item.code)} className="label1">
164
+ <li
165
+ key={`item-list-4-${index}`}
166
+ className="w-[172px]"
167
+ >
168
+ <Link
169
+ href={getLocationHref(item.code)}
170
+ className="label1"
171
+ >
150
172
  {item.name}
151
173
  </Link>
152
174
  </li>
153
- ) : <li key={`empty-4-${index}`} aria-hidden="true" />
175
+ ) : (
176
+ <li key={`empty-4-${index}`} aria-hidden="true" />
177
+ )
154
178
  );
155
179
  })()}
156
180
  </ul>
@@ -10,6 +10,7 @@ export type FindKineticProps = {
10
10
  maxWidth?: boolean;
11
11
  color?: "dark" | "light";
12
12
  columns?: 2 | 3 | 4;
13
+ addTrailingSlash?: boolean;
13
14
  };
14
15
 
15
16
  export type ThemeKey =