Skip to content

fix: Routing base case#1

Merged
fulldump merged 1 commit intomasterfrom
fix/routing-base-case
Sep 28, 2018
Merged

fix: Routing base case#1
fulldump merged 1 commit intomasterfrom
fix/routing-base-case

Conversation

@fulldump
Copy link
Owner

Explanation:
If we have a route like this '/hello/world/' splitting by slashes:

["", "hello", "world", ""]

By default, leading slash is trimmed out, so actually we have:

["hello", "world", ""]

Now the trailing item (empty string) should be a child of the resource
itself (that allow you to handle resources ending in slash). That is
working now.

The second part is the base case. Since leading slash is being trimmed
out, these two cases should be equivalent:

r.Resource("") == r.Resource("/")

Now it is not! r.Resource("") is the r itself whereas r.Resource("/")
is a child node with the empty string path.

With this fix behavior is consistent in all cases.

Explanation:
If we have a route like this '/hello/world/' splitting by slashes:

```
["", "hello", "world", ""]
```

By default, leading slash is trimmed out, so actually we have:

```
["hello", "world", ""]
```

Now the trailing item (empty string) should be a child of the resource
itself (that allow you to handle resources ending in slash). That is
working now.

The second part is the base case. Since leading slash is being trimmed
out, these two cases should be equivalent:

```
r.Resource("") == r.Resource("/")
```

Now it is not! `r.Resource("")` is the `r` itself whereas `r.Resource("/")`
is a child node with the empty string path.


With this fix behavior is consistent in all cases.
@fulldump fulldump merged commit 37652c1 into master Sep 28, 2018
@fulldump fulldump deleted the fix/routing-base-case branch September 28, 2018 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant