diff --git a/HISTORY.md b/HISTORY.md
index 1f34fd8e..1da98277 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -2,6 +2,11 @@
**How to upgrade**: remove your `$GOPATH/src/github.com/kataras` folder, open your command-line and execute this command: `go get -u github.com/kataras/iris/iris`.
+## 4.4.1 -> 4.4.3
+
+- **FIX**: CORS
+- **FIX**: Unexpected Party root's route slash when `DisablePathCorrection` is false(default), as reported [here](https://github.com/kataras/iris/issues/453)
+
## 4.4.0 -> 4.4.1
- **NEW**: Template PreRenders, as requested [here](https://github.com/kataras/iris/issues/412).
diff --git a/README.md b/README.md
index 6f499b96..ddf2a26e 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@
-
+
@@ -222,7 +222,7 @@ I recommend writing your API tests using this new library, [httpexpect](https://
Versioning
------------
-Current: **v4.4.2**
+Current: **v4.4.3**
> Iris is an active project
@@ -258,7 +258,7 @@ This project is licensed under the [MIT License](LICENSE), Copyright (c) 2016 Ge
[Travis]: http://travis-ci.org/kataras/iris
[License Widget]: https://img.shields.io/badge/license-MIT%20%20License%20-E91E63.svg?style=flat-square
[License]: https://github.com/kataras/iris/blob/master/LICENSE
-[Release Widget]: https://img.shields.io/badge/release-4.4.2%20-blue.svg?style=flat-square
+[Release Widget]: https://img.shields.io/badge/release-4.4.3%20-blue.svg?style=flat-square
[Release]: https://github.com/kataras/iris/releases
[Chat Widget]: https://img.shields.io/badge/community-chat%20-00BCD4.svg?style=flat-square
[Chat]: https://kataras.rocket.chat/channel/iris
diff --git a/http_test.go b/http_test.go
index 179c62fe..422f96dd 100644
--- a/http_test.go
+++ b/http_test.go
@@ -8,12 +8,13 @@ CONTRIBUTE & DISCUSSION ABOUT TESTS TO: https://github.com/iris-contrib/tests
import (
"fmt"
- "github.com/valyala/fasthttp"
"io/ioutil"
"os"
"testing"
"time"
+ "github.com/valyala/fasthttp"
+
"github.com/gavv/httpexpect"
)
@@ -408,7 +409,7 @@ func TestMuxSimpleParty(t *testing.T) {
}
Default.Config.VHost = "0.0.0.0:8080"
- //Default.Config.Tester.Debug = true
+ Default.Config.Tester.Debug = true
//Default.Config.Tester.ExplicitURL = true
e := Tester(t)
@@ -420,7 +421,7 @@ func TestMuxSimpleParty(t *testing.T) {
}
// run the tests
- request("/party1/")
+ request("/party1")
request("/party1/path1")
request("/party1/path2")
request("/party1/namedpath/theparam1/something/theparam2")
diff --git a/iris.go b/iris.go
index 2cec46be..4cb2cf64 100644
--- a/iris.go
+++ b/iris.go
@@ -52,15 +52,6 @@ package iris // import "github.com/kataras/iris"
import (
"fmt"
- "github.com/gavv/httpexpect"
- "github.com/kataras/go-errors"
- "github.com/kataras/go-fs"
- "github.com/kataras/go-serializer"
- "github.com/kataras/go-sessions"
- "github.com/kataras/go-template"
- "github.com/kataras/go-template/html"
- "github.com/kataras/iris/utils"
- "github.com/valyala/fasthttp"
"log"
"net"
"net/http"
@@ -75,11 +66,21 @@ import (
"syscall"
"testing"
"time"
+
+ "github.com/gavv/httpexpect"
+ "github.com/kataras/go-errors"
+ "github.com/kataras/go-fs"
+ "github.com/kataras/go-serializer"
+ "github.com/kataras/go-sessions"
+ "github.com/kataras/go-template"
+ "github.com/kataras/go-template/html"
+ "github.com/kataras/iris/utils"
+ "github.com/valyala/fasthttp"
)
const (
// Version is the current version of the Iris web framework
- Version = "4.4.2"
+ Version = "4.4.3"
banner = ` _____ _
|_ _| (_)
@@ -240,6 +241,9 @@ func New(setters ...OptionSetter) *Framework {
{
// set the servemux, which will provide us the public API also, with its context pool
mux := newServeMux(s.Logger)
+ mux.escapePath = !s.Config.DisablePathCorrection
+ // escapePath re-setted on .Set and after build, it's the only config which should be setted before any other route(party-releated) method called.
+
mux.onLookup = s.Plugins.DoPreLookup
s.contextPool.New = func() interface{} {
return &Context{framework: s}
@@ -267,6 +271,10 @@ func (s *Framework) Set(setters ...OptionSetter) {
for _, setter := range setters {
setter.Set(s.Config)
}
+
+ if s.muxAPI != nil && s.mux != nil { // if called after .New
+ s.mux.escapePath = !s.Config.DisablePathCorrection // then re-set the mux' pathEscape, which should be setted BEFORE any route-releated method call
+ }
}
// Must panics on error, it panics on registed iris' logger
@@ -1328,7 +1336,7 @@ func (api *muxAPI) Handle(method string, registedPath string, handlers ...Handle
return nil
}
- fullpath := api.relativePath + registedPath // keep the last "/" if any, "/xyz/"
+ fullpath := api.relativePath + registedPath // for now, keep the last "/" if any, "/xyz/"
middleware := joinMiddleware(api.middleware, handlers)
@@ -1340,6 +1348,16 @@ func (api *muxAPI) Handle(method string, registedPath string, handlers ...Handle
subdomain = fullpath[0 : dotWSlashIdx+1] // admin.
path = fullpath[dotWSlashIdx+1:] // /
}
+ // we splitted the path and subdomain parts so we're ready to check only the path, otherwise we will had problems with subdomains
+ if api.mux.correctPath {
+ // remove last "/" if any, "/xyz/"
+ if len(path) > 1 { // if it's the root, then keep it*
+ if path[len(path)-1] == slashByte {
+ // ok we are inside /xyz/
+ path = path[0 : len(path)-1]
+ }
+ }
+ }
path = strings.Replace(path, "//", "/", -1) // fix the path if double //