mehrancodes / laravel-harbor

a cli tool to Quickly create on-demand preview environment for your app on Laravel Forge.
https://www.laravel-harbor.com
MIT License
75 stars 7 forks source link

Fix: Sluggify the database name #89

Closed shawnhooper closed 7 months ago

shawnhooper commented 7 months ago

Fixes #88

mehrancodes commented 7 months ago

I also added the new function to the RemoveDatabaseUser class. Did a couple of tests using other characters (FORGE_DB_NAME=abc+11@database) to ensure we are safe but we got forge validation error:

  FAIL    ---> The name must only contain letters, numbers, and underscores.
  FAIL    ---> The user field must only contain letters, numbers, dashes, and underscores.

I have added a regex rule to the db_name to ensure we throw err before the site gets created with crash. This allows us to keep the current behavior when db_name not provided.

mehrancodes commented 7 months ago

I tried to load the validation messages from the resources/lang/en/validation but Harbor loads messages from default vendor path. We may need some time to fix this, but for now I have specified db_name.regex err message while doing validation.

mehrancodes commented 7 months ago

It's time to merge if we're all good. I'd love to hear what you think!

shawnhooper commented 7 months ago

This looks good to me @mehrancodes, I'd say merge it.

I do look forward to having some automated tests in this project... a task for another day.

mehrancodes commented 7 months ago

That's great to hear! I appreciate it! It's now merged and released.