-
Notifications
You must be signed in to change notification settings - Fork 0
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
Count link redirects #14
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.
👌
One minor remark regarding naming things :)
pkg/app/router.go
Outdated
@@ -92,6 +93,15 @@ func redirectHandler(w http.ResponseWriter, r *http.Request) { | |||
return | |||
} | |||
|
|||
// To avoid redirect loop | |||
if link.URL == link.ID { | |||
http.Error(w, "Link id must be different than url", http.StatusBadRequest) |
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.
Link id
is, IMHO, bit confusing. As a user I would probably confused what this ID is. As far as I understand now id
is url part provided by the user? If so, I'd recommend changing it to something like value
or something similar :)
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.
Good suggestion! I've renamed it and added some comments to structs
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.
Nice one!
@@ -92,6 +92,15 @@ func redirectHandler(w http.ResponseWriter, r *http.Request) { | |||
return | |||
} | |||
|
|||
// To avoid redirect loop | |||
if link.URL == link.Value { | |||
http.Error(w, "Alternative url value must be different than the url", http.StatusBadRequest) |
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.
👍
Related to #2