Skip to content

Commit

Permalink
Adds condition to not implement routes if custom routes are provided.
Browse files Browse the repository at this point in the history
  • Loading branch information
yordadev committed Sep 20, 2024
1 parent 2262409 commit f79e748
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/Utility/Config/urlshortener.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@
'Referer' => getenv('APP_URL', 'localhost:1337'),
],
],
'use_custom_routes' => false,
'allow_duplicate_long_links' => getenv('ALLOW_DUPLICATE_LONG_LINKS', true),
];
24 changes: 14 additions & 10 deletions src/Utility/routes.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<?php

Route::middleware('web')->group(function () {
Route::get(
config('urlshortener.branding.prefix').'/{identifier}',
YorCreative\UrlShortener\Actions\ShortUrlRedirect::class
);
use Illuminate\Routing\Route;

Route::post(
config('urlshortener.branding.prefix').'/protected',
YorCreative\UrlShortener\Actions\AttemptProtected::class
)->name('urlshortener.attempt.protected');
});
if(config('urlshortener.use_custom_routes')) {
Route::middleware('web')->group(function () {
Route::get(
config('urlshortener.branding.prefix').'/{identifier}',
YorCreative\UrlShortener\Actions\ShortUrlRedirect::class
);

Route::post(
config('urlshortener.branding.prefix').'/protected',
YorCreative\UrlShortener\Actions\AttemptProtected::class
)->name('urlshortener.attempt.protected');
});
}

0 comments on commit f79e748

Please sign in to comment.