Skip to content

Commit

Permalink
[Major Bug] Allow route variables to be placed anywhere
Browse files Browse the repository at this point in the history
The Router regex wouldn't allow :param variable inside a route e.g. /posts-:username, this commit fixes that.
  • Loading branch information
DronRathore authored Jul 5, 2017
1 parent 27f8028 commit 324ebb1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func CompileRegex(url string) *regexp.Regexp {
buffer = ""
i++
} else {
if url[i] == ':' && ( (i-1 >=0 && url[i-1] == '/') || (i-1 == -1)) {
if url[i] == ':' && ( (i-1 > 0 && url[i-1] == '/') || (i-1 == -1) || (i-1 > 0)) {
// a variable found, lets read it
var tempbuffer = "(?P<"
var variableName = ""
Expand Down

0 comments on commit 324ebb1

Please sign in to comment.