Skip to content

Commit

Permalink
conflicting
Browse files Browse the repository at this point in the history
  • Loading branch information
realodix committed Feb 3, 2025
1 parent dc6c6b5 commit 1d2c912
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions app/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,28 @@ public static function urlFormat(
}

/**
* List of potentially colliding routes with shortened link keywords.
* A list of route paths that could potentially conflict with shortened link
* keywords.
*
* This method retrieves all defined routes and filters them to identify potential
* conflicts with the format and reserved keywords used for shortened links.
*
* @return array
*/
public static function routeCollisionList()
{
return collect(\Illuminate\Support\Facades\Route::getRoutes()->get())
->map(fn(\Illuminate\Routing\Route $route) => $route->uri)
->pipe(fn($value) => self::collisionCandidateFilter($value))
->pipe(fn($paths) => self::collisionCandidateFilter($paths))
->toArray();
}

/**
* List of files/folders in the public/ directory that will potentially collide
* with shortened link keywords.
* A list of file/folder names in the public directory that could potentially
* conflict with shortened link keywords.
*
* This method scans the public directory and filters the file/folder names
* to identify potential conflicts with keywords used for shortened links.
*
* @return array
*/
Expand All @@ -99,11 +106,17 @@ public static function publicPathCollisionList()
}

return collect($publicPathList)
->pipe(fn($value) => self::collisionCandidateFilter($value))
->pipe(fn($paths) => self::collisionCandidateFilter($paths))
->toArray();
}

/**
* Filters a collection of strings to identify potential collisions with keywords.
*
* The resulting collection contains unique strings that "could potentially"
* clash with generated short link keywords. These strings are considered
* "collision candidates" because they have the same format as valid keywords
*
* @param \Illuminate\Support\Collection $value
* @return \Illuminate\Support\Collection
*/
Expand Down

0 comments on commit 1d2c912

Please sign in to comment.