Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid wrapping Artisan command --url option with url() helper when possible #361

Merged
merged 4 commits into from
Nov 13, 2020

Conversation

bakerkretzmar
Copy link
Collaborator

This PR closes #359, but note that it doesn't fix that particular issue—the cause of that issue is an invalid APP_URL, which is a case that Laravel and Ziggy do not officially support.

What that issue raised, though, was the fact that we're now applying the url() helper inconsistently. In #334 we updated the Ziggy class to prefer APP_URL over the url() helper, but I missed the fact that the CommandRouteGenerator class was still always wrapping its --url option with the url() helper—even when the --url option is null.

This PR ensures that if no --url option is passed, the generate command passes that null option on to the Ziggy class to handle properly.

Before

  • Not passing a --url option to php artisan ziggy:generate uses url('/')
  • Passing a valid URL to the --url option uses that URL directly
  • Passing anything else to the --url option uses url($this->option('url'))

After

  • Not passing a --url option to php artisan ziggy:generate uses config('app.url', url('/'))
  • Passing a valid URL to the --url option uses that URL directly (unchanged)
  • Passing anything else to the --url option uses url($this->option('url')) (unchanged)

@bakerkretzmar bakerkretzmar merged commit 865333a into main Nov 13, 2020
@bakerkretzmar bakerkretzmar deleted the jbk/url-localhost-bug branch November 13, 2020 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

url.match Regex returns null
1 participant