aboutsummaryrefslogtreecommitdiff
path: root/uri_test.go
diff options
context:
space:
mode:
authorGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-01-04 14:23:07 +0200
committerGravatar Aliaksandr Valialkin <valyala@gmail.com> 2016-01-04 14:23:07 +0200
commit9b0b87c951bd88a3e579d8f0a9ee5880920e9a65 (patch)
treeabbb2b04a6d845b6be1ee5660ed531daa23ca735 /uri_test.go
parentAdded short term TODO items (diff)
downloadfasthttp-9b0b87c951bd88a3e579d8f0a9ee5880920e9a65.tar.gz
fasthttp-9b0b87c951bd88a3e579d8f0a9ee5880920e9a65.tar.bz2
fasthttp-9b0b87c951bd88a3e579d8f0a9ee5880920e9a65.zip
Added URI.LastPathSegment helper function
Diffstat (limited to 'uri_test.go')
-rw-r--r--uri_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/uri_test.go b/uri_test.go
index 687c2cf..71191cd 100644
--- a/uri_test.go
+++ b/uri_test.go
@@ -5,6 +5,23 @@ import (
"testing"
)
+func TestLastPathSegment(t *testing.T) {
+ testLastPathSegment(t, "", "")
+ testLastPathSegment(t, "/", "")
+ testLastPathSegment(t, "/foo/bar/", "")
+ testLastPathSegment(t, "/foobar.js", "foobar.js")
+ testLastPathSegment(t, "/foo/bar/baz.html", "baz.html")
+}
+
+func testLastPathSegment(t *testing.T, path, expectedSegment string) {
+ var u URI
+ u.SetPath(path)
+ segment := u.LastPathSegment()
+ if string(segment) != expectedSegment {
+ t.Fatalf("unexpected last path segment for path %q: %q. Expecting %q", path, segment, expectedSegment)
+ }
+}
+
func TestURIPathEscape(t *testing.T) {
testURIPathEscape(t, "/foo/bar", "/foo/bar")
testURIPathEscape(t, "/f_o-o=b:ar,b.c&q", "/f_o-o=b:ar,b.c&q")