-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
Add current_page? helper for pages. #1074
Add current_page? helper for pages. #1074
Conversation
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.
Hey, thanks for taking a look at this! I just left a comments.
Just pushed an updated version where host with port are tested as well if the given value is a full uri. For example: # Visiting https://example.com/action
view.current_page?("https://example.com/action")
# # => true
# Visiting https://example.io/action
view.current_page?("https://example.com/action")
# # => false But: # Visiting https://example.com/action
view.current_page?("http://example.com/action")
# # => true Might be confusing. UPDATE As discussed in #1073, we'll leave out the schema since https is a requirement these days. |
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.
Really wonderful stuff. Just a couple specs for the RouteHelper version. Overall looks fantastic. And thanks for adding docs
I assumed this was good to go, but just thought of something. The query params probably need to be unescaped before testing against the given value. |
Ok, this is the last bit I think. Now uri encoded query params are properly decoded before testing. |
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.
Looks perfect! Nice catches and great specs
Purpose
Implementing #1073.
Description
This adds the
current_page?
helper with similar functionality like the one in Rails. Although, it does not cover all Rails' cases. What it does not do:protocol
andport
I'm not quite sure if they are relevant or even possible. Looking at the available data in a request, I wonder if it is even feasible to implement point 3. There is no notion of the protocol, but even then, would we even need to test the protocol?
Checklist
crystal tool format spec src
./script/setup
./script/test