Sfoglia il codice sorgente

Potential fix for code scanning alert no. 779: Type confusion through parameter tampering

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Yuki Takei 10 mesi fa
parent
commit
aa7d89e63b
1 ha cambiato i file con 2 aggiunte e 2 eliminazioni
  1. 2 2
      packages/core/src/utils/path-utils.ts

+ 2 - 2
packages/core/src/utils/path-utils.ts

@@ -7,7 +7,7 @@ interface PathParts {
 }
 }
 
 
 function parsePath(path: string): PathParts | null {
 function parsePath(path: string): PathParts | null {
-  if (!path || path === '') return null;
+  if (typeof path !== 'string' || !path || path === '') return null;
 
 
   // Special case for root path
   // Special case for root path
   if (path === '/') {
   if (path === '/') {
@@ -111,7 +111,7 @@ export function removeTrailingSlash(path: string): string {
  * A short-hand method to add heading slash and remove trailing slash.
  * A short-hand method to add heading slash and remove trailing slash.
  */
  */
 export function normalizePath(path: string): string {
 export function normalizePath(path: string): string {
-  if (path === '' || path === '/') {
+  if (typeof path !== 'string' || path === '' || path === '/') {
     return '/';
     return '/';
   }
   }