Skip to content

Commit 37652c1

Browse files
authored
Merge pull request #1 from fulldump/fix/routing-base-case
fix: Routing base case
2 parents c450642 + 519cd7e commit 37652c1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

resource.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ func (r *R) resourceParts(parts []string) *R {
101101
// Resource defines a new resource below current resource
102102
func (r *R) Resource(locator string) *R {
103103

104-
locator = strings.TrimPrefix(locator, "/")
105104
if locator == "" {
106105
return r
107106
}
108107

108+
locator = strings.TrimPrefix(locator, "/")
109109
parts := strings.Split(locator, "/")
110110

111111
return r.resourceParts(parts)

resource_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestR_Resource_BaseCaseSlash(t *testing.T) {
3636
root := NewResource()
3737
r := root.Resource("/")
3838

39-
AssertEqual(t, r, root)
39+
AssertEqual(t, r, root.children[0])
4040
}
4141

4242
func TestR_Resource_NextCase(t *testing.T) {

0 commit comments

Comments
 (0)