diff --git a/laravel/app/Http/Controllers/ShortlinkController.php b/laravel/app/Http/Controllers/ShortlinkController.php index 886f293..a0ec41e 100644 --- a/laravel/app/Http/Controllers/ShortlinkController.php +++ b/laravel/app/Http/Controllers/ShortlinkController.php @@ -14,6 +14,12 @@ class ShortlinkController extends Controller return response()->json(['error' => 'Unauthorized'], 401); } + if (strlen($request->url) > 5000) { + return back()->withErrors([ + 'error' => 'The URL provided is too long' + ]); + } + try { $request->validate([ 'url' => 'required|url' @@ -41,7 +47,7 @@ class ShortlinkController extends Controller return redirect("/l/{$shortlink->shortid}"); } catch (\Exception $e) { return back()->withErrors([ - 'error' => $e->getMessage() + 'error' => 'An error occurred while creating the shortlink' ]); } } diff --git a/laravel/database/migrations/2024_06_10_010339_create_shortlinks_table.php b/laravel/database/migrations/2024_06_10_010339_create_shortlinks_table.php index 0026167..5c55e7c 100644 --- a/laravel/database/migrations/2024_06_10_010339_create_shortlinks_table.php +++ b/laravel/database/migrations/2024_06_10_010339_create_shortlinks_table.php @@ -14,7 +14,7 @@ return new class extends Migration Schema::create('shortlinks', function (Blueprint $table) { $table->id(); $table->string('shortid')->unique(); - $table->string('destination'); + $table->string('destination', 5000); $table->foreignId('user_id')->references('id')->on('users'); $table->integer('max_clicks')->default(0); $table->boolean('deleted')->default(false); diff --git a/laravel/public/css/default.css b/laravel/public/css/default.css index 88de47f..0c281f6 100644 --- a/laravel/public/css/default.css +++ b/laravel/public/css/default.css @@ -383,7 +383,7 @@ button { justify-content: space-between; } -#graphs h2, #stats h2 { +#graphs h2, #stats h2, #table-container h2 { margin-bottom: 20px; } @@ -407,6 +407,14 @@ table td, table th { table td { border-top: 1px solid #888; + white-space: nowrap; +} + +table td.table-truncate { + white-space: normal; + overflow: hidden; + text-overflow: ellipsis; + word-break: break-all; } table th, table td { @@ -421,6 +429,11 @@ table th:last-child, table td:last-child { border-right: none; } +.destination { + height: 1.2em; + overflow: hidden; +} + footer { margin-top: auto; height: 50px; diff --git a/laravel/resources/views/details.blade.php b/laravel/resources/views/details.blade.php index f119c4d..92b89f3 100644 --- a/laravel/resources/views/details.blade.php +++ b/laravel/resources/views/details.blade.php @@ -36,6 +36,8 @@ expires_at != null) value="{{ Carbon\Carbon::parse($shortlink->expires_at)->format('Y-m-d') }}" + @else + value="{{ Carbon\Carbon::now()->format('Y-m-d') }}" @endif > diff --git a/laravel/resources/views/profile.blade.php b/laravel/resources/views/profile.blade.php index dcb1270..fbb60f5 100644 --- a/laravel/resources/views/profile.blade.php +++ b/laravel/resources/views/profile.blade.php @@ -14,19 +14,27 @@
Created at: {{ Auth::user()->created_at }}
Link | -Destination | -Created at | -|||
---|---|---|---|---|---|
shortid) }}">{{ $shortlink['shortid'] }} | -{{ $shortlink['destination'] }} | -{{ Carbon\Carbon::parse($shortlink->created_at)->format('M jS Y') }} | +Link | +Destination | +Created at |
shortid) }}">{{ $shortlink['shortid'] }} | +{{ $shortlink['destination'] }} |
+ {{ Carbon\Carbon::parse($shortlink->created_at)->format('M jS Y') }} | +|||
Shorten a new link | +