-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
Adding period char to url regex in the makeHandler method. #33
Conversation
…hub usernames, org names, and repo names
See #32 (comment). It appears periods are not allowed in usernames/organizations. Also, this regex will match repo names "." and ".." both of which are not allowed, and would cause the url path to be misinterpreted anyway. |
@shurcooL replied back #32 (comment) Good catch on the usernames/org names. Also good catch on repos that simply consist of I'll look at updating the pull request to better reflect what github allows in repo names. |
@shurcooL I updated the pull request to account for the cases you pointed out. If you think there is a more clean way to filter out the |
@@ -12,13 +12,21 @@ import ( | |||
|
|||
func makeHandler(name string, fn func(http.ResponseWriter, *http.Request, string, string)) http.HandlerFunc { |
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.
Are you sure makeHandler
is used only for generating handlers that expect a name, followed by github username, then github repo?
It's not documented so it's hard to tell.
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.
Line 30 fn(w, r, m[1], m[2])
seems to expect m[1]
and m[2]
to be available slice indices. Now if thats a good thing or not is a different question.
I assumed that line 17 validPath.FindStringSubmatch(r.URL.Path)
returns nil
if validPath
can't produce a slice of m[0, 1, 2]
so that is why line 30 can expect m[2]
to be valid.
I say all this assuming the same things you mentioned above around github usernames and repos. 😅
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.
To clarify my concern/question, you've added GitHub-specific rules to a func named makeHandler
. If that func happens to be used to generate, for example, non-GitHub-related handlers, then it's not correct (because those non-GitHub-related handlers may not want to accept periods at all).
I'm not familiar with this codebase so I can only go based on the name of func and its documentation, which doesn't make it clear.
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.
If you go to the webpage http://goreportcard.com/ it seems to only allow github repos.
My understanding after playing with this codebase is the makeHandler
function creates all the handlers for other routes including /badge
and /report
, but those need a github username and repo as well. Im hoping the owners of this repo can shed light on if this change breaks anything, but so far in my local testing it looks good.
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.
Great, thanks for confirming that. I was only 80% confident that was the case. :)
I'm really not a fan of regexes in general, so I'm all in favor of having logic moved outside as you've done. I think it's good. LGTM. |
Ah, I see. You just removed a file you inadvertently added as part of this PR. I missed that.
IMO that's not necessary. It's a pretty uncommon occurrence because you typically pick which files to commit, and it's easily caught during review. I personally prefer having as empty a Also, in order to save time, I typically do |
Yes, I do tend to do On a side note i'm interested to hear what operating specific files or non-native files you would not include within a Not trying to push back, just interested in your view point. 😃 |
I'm happy to share my view point.
One example I've seen that caused occasional trouble is the Another example would be ignoring the binary itself (for convenience of being able to do
It's up to you, for all my new Go packages, I start with a blank repository (without a Take a look at my repositories. The only ones that have |
Adding period char to url regex in the makeHandler method.
This should fix #32.