mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 02:17:05 +00:00
remove any trailing slash that may passed on StaticEmbeddedHandler (although all examples shows the correct way but you never know)
Former-commit-id: 50ab9ddb2e738b4061622ac9ebcfec30e0cdecfa
This commit is contained in:
@@ -42,6 +42,14 @@ func StaticEmbeddedHandler(vdir string, assetFn func(name string) ([]byte, error
|
||||
if vdir[0] == '/' || vdir[0] == os.PathSeparator { // second check for /something, (or ./something if we had dot on 0 it will be removed
|
||||
vdir = vdir[1:]
|
||||
}
|
||||
|
||||
// check for trailing slashes because new users may be do that by mistake
|
||||
// although all examples are showing the correct way but you never know
|
||||
// i.e "./assets/" is not correct, if was inside "./assets".
|
||||
// remove last "/".
|
||||
if trailingSlashIdx := len(vdir) - 1; vdir[trailingSlashIdx] == '/' {
|
||||
vdir = vdir[0:trailingSlashIdx]
|
||||
}
|
||||
}
|
||||
|
||||
// collect the names we are care for,
|
||||
|
||||
Reference in New Issue
Block a user