fix: anchor function not updating hostname when Config\App::$allowedHostnames is set#9492
Closed
devunee wants to merge 2 commits intocodeigniter4:developfrom
Closed
fix: anchor function not updating hostname when Config\App::$allowedHostnames is set#9492devunee wants to merge 2 commits intocodeigniter4:developfrom
devunee wants to merge 2 commits intocodeigniter4:developfrom
Conversation
Fixes function "anchor" not updating the hostname even when it is set in Config\App::$allowedHostnames and when the current URL matches.
|
Hi there, @devunee! 👋 Thank you for sending this PR! We expect the following in all Pull Requests (PRs).
Important We expect all code changes or bug-fixes to be accompanied by one or more tests added to our test suite to prove the code works. If pull requests do not comply with the above, they will likely be closed. Since we are a team of volunteers, we don't have any more time to work Sincerely, the mergeable bot 🤖 |
Member
|
Hey @devunee, can you add some tests to confirm that your fix is working as intended? |
Member
|
Closing as abandoned. If this is still needed, please open a new PR with tests. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When you have set Config\App::$allowedHostnames the hostname should be set in it if the current URL matches. This is working as expected with with the functions base_url and site_url but NOT working with anchor.
It isn't working as expected because when the anchor function is called with a NULL $altConfig parameter, this parameter is modified to the default Config\App value, then it calls site_url and SiteUri::siteUrl with the default Config\App value instead of NULL which causes the line of code that checks for the host and updates it to be ignored.
The fix is quite simple, the function anchor should keep the parameter $altConfig as NULL and do not modify it to the default Config\App value because this will be done by the SiteUri::siteUrl function.
Checklist: