465ed4b7 by astaxie

fix router's bug

1 parent 2f02653b
...@@ -51,12 +51,12 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface) { ...@@ -51,12 +51,12 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface) {
51 //match /post/:username:word ([\w]+) 51 //match /post/:username:word ([\w]+)
52 } else if lindex := strings.LastIndex(part, ":"); lindex != 0 { 52 } else if lindex := strings.LastIndex(part, ":"); lindex != 0 {
53 switch part[lindex:] { 53 switch part[lindex:] {
54 case "int": 54 case ":int":
55 expr = "([0-9]+)" 55 expr = "([0-9]+)"
56 part = part[:index] 56 part = part[:lindex]
57 case "word": 57 case ":word":
58 expr = `([\w]+)` 58 expr = `([\w]+)`
59 part = part[:index] 59 part = part[:lindex]
60 } 60 }
61 } 61 }
62 params[j] = part 62 params[j] = part
...@@ -67,10 +67,9 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface) { ...@@ -67,10 +67,9 @@ func (p *ControllerRegistor) Add(pattern string, c ControllerInterface) {
67 expr := "(.+)" 67 expr := "(.+)"
68 if part == "*.*" { 68 if part == "*.*" {
69 params[j] = ":path" 69 params[j] = ":path"
70 parts[j] = "([^.]+)." 70 parts[i] = "([^.]+).([^.]+)"
71 j++ 71 j++
72 params[j] = ":ext" 72 params[j] = ":ext"
73 parts[j] = "([^.]+)"
74 j++ 73 j++
75 } else { 74 } else {
76 params[j] = ":splat" 75 params[j] = ":splat"
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!