-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Improve behaviour when a site URL is not explicitly set #1726
Improve behaviour when a site URL is not explicitly set #1726
Conversation
8efa960
to
e71b1d5
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1726 +/- ##
============================================
- Coverage 99.97% 99.95% -0.03%
- Complexity 1746 1747 +1
============================================
Files 181 181
Lines 4667 4670 +3
============================================
+ Hits 4666 4668 +2
- Misses 1 2 +1 ☔ View full report in Codecov by Sentry. |
8ed2cc1
to
0439c16
Compare
We now return the relative path even if the base URL is not set, as this is more likely to be the desired behavior the user's expecting. If the user is trying to get the base URL, but it's not set, we throw the exception.
0439c16
to
3cfa8a5
Compare
This better matches the documented method description of "Check if a site base URL has been set in config (or .env).", as this value is `localhost` by default and thus not set by the user. Revert "Method `Hyde::hasSiteUrl()` now returns false when URL is for localhost" This reverts commit 8a13ad9. Reapply "Method `Hyde::hasSiteUrl()` now returns false when URL is for localhost" This reverts commit 0c4ab34. Update HelpersTest.php
Only the Markdown pages can be made like this
return $path; | ||
} | ||
|
||
// User is trying to get the base URL, but it's not set | ||
throw new BaseUrlNotSetException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might consider this for deprecation
The hasSiteUrl method now checks if the URL is for localhost
Abstract
We're getting some issues by Hyde using
localhost
as the default site URL. Initially, this PR will target the 1.x branch because I consider these things to be bugs that should be fixed in v1, however, there may be side effects of this: primarily that output HTML will change - but I do not think anyone will depend on those undesired effects before this patch, since localhost is never desired in production. This will resolve #1720Expanding on the reasoning behind allowing this in 1.x: Since v1 is LTS, I don't want to leave those users hanging with what is in my opinion a bug, that localhost links can "leak" through production. And I think the only way to fix this is by changing some logic which could have side effects. But I think I am okay with that tradeoff as it stands now, especially since I think any possible usages that may be affected probably don't actually desire the logic we have now.
Major changes
Method
Hyde::hasSiteUrl()
now returns false if URL is localhostThis better matches the documented method description of "Check if a site base URL has been set in config (or .env).", as this value is
localhost
by default and thus not set by the user.Method
Hyde::url()
now resolves relative paths instead of throwingWe now return the relative path even if the base URL is not set, as this is more likely to be the desired behavior the user's expecting. If the user is trying to get the base URL, but it's not set, we throw the exception.