Skip to content

Commit

Permalink
Fixed validation error on Vanity URLS
Browse files Browse the repository at this point in the history
  • Loading branch information
spitfire305 committed Nov 2, 2023
1 parent 4943167 commit 00d195c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Http\Controllers\Calendars\Api;
namespace App\Http\Controllers\Campaign;

use App\Http\Controllers\Controller;
use App\Http\Requests\Campaigns\Vanity;
Expand Down
4 changes: 4 additions & 0 deletions app/Rules/Vanity.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class Vanity implements ValidationRule
public function validate(string $attribute, mixed $value, Closure $fail): void
{
$value = trim($value);
if (strpos($value, '/')) {
$fail(__('campaigns/vanity.rule2', ['field' => $attribute]));
}

if (!preg_match('`[a-zA-Z]+`', $value)) {
$fail(__('campaigns/vanity.rule', ['field' => $attribute]));
}
Expand Down
1 change: 1 addition & 0 deletions lang/en/campaigns/vanity.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
'available' => 'The name :vanity is available!',
'helper' => 'Make the campaign stand out with a unique name in the URL. For example, instead of showing up as :default, have every page\'s url in the campaign show up as :example. This field can only be set once and is permanent. Learn more about this feature in our :learn-more.',
'rule' => 'The :field field needs at least one alphabetical character.',
'rule2' => 'The :field field doesn\'t allow the following character: /.',
'set' => 'The campaign\'s vanity URL is permanently set to :vanity.',
];
2 changes: 1 addition & 1 deletion routes/campaigns/campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,4 @@


Route::get('/w/{campaign}/confirm-delete', [\App\Http\Controllers\ConfirmController::class, 'index'])->name('confirm-delete');
Route::post('/w/{campaign}/vanity-validate', [\App\Http\Controllers\Calendars\Api\VanityController::class, 'index'])->name('campaign.vanity-validate');
Route::post('/w/{campaign}/vanity-validate', [\App\Http\Controllers\Campaign\VanityController::class, 'index'])->name('campaign.vanity-validate');

0 comments on commit 00d195c

Please sign in to comment.