Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::redirect('/', 'https://laravel.com/docs', 302);

Route::get('/{name}', function (Request $request, $name) {
Validator::validate(['name' => $name], ['name' => 'string|alpha_dash']);
try {
Validator::validate(['name' => $name], ['name' => 'string|alpha_dash']);
} catch (ValidationException $e) {
return response('Invalid site name. Please only use alpha-numeric characters, dashes, and underscores.', 400);
}

$php = $request->query('php', '81');

Expand Down
13 changes: 13 additions & 0 deletions tests/Feature/SailServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

class SailServerTest extends TestCase
{
public function test_the_homepage_redirects_to_the_laravel_docs()
{
$this->get('/')->assertRedirect('https://laravel.com/docs');
}

public function test_it_can_return_the_sail_install_script()
{
$response = $this->get('/example-app');
Expand All @@ -30,4 +35,12 @@ public function test_it_adds_the_devcontainer_upon_request()
$response->assertStatus(200);
$response->assertSee('bash -c "laravel new example-app && cd example-app && php ./artisan sail:install --with=postgres --devcontainer"', false);
}

public function test_it_does_not_accepts_domains_with_a_dot()
{
$response = $this->get('/foo.test');

$response->assertStatus(400);
$response->assertSee('Invalid site name. Please only use alpha-numeric characters, dashes and underscores.');
}
}