Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [Fix]: unhandle in strictmode #2055

Merged
merged 4 commits into from Sep 7, 2022

Conversation

wangjq4214
Copy link
Member

@wangjq4214 wangjq4214 commented Aug 27, 2022

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
Explain the details for making this change. What existing problem does the pull request solve?

Fixes #2044

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • For new functionalities I follow the inspiration of the express js framework and built them similar in usage
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation - https://github.com/gofiber/docs for https://docs.gofiber.io/
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • If new dependencies exist, I have checked that they are really necessary and agreed with the maintainers/community (we want to have as few dependencies as possible)
  • I tried to make my code as fast as possible with as few allocations as possible

Commit formatting:

Use emojis on commit messages so it provides an easy way of identifying the purpose or intention of a commit. Check out the emoji cheatsheet here: https://gitmoji.carloscuesta.me/

@wangjq4214 wangjq4214 changed the title fix: unhandle in strictmode 🐛 [Fix]: unhandle in strictmode Aug 27, 2022
@ReneWerner87
Copy link
Member

please provide or update some testcases for the strict mode

@wangjq4214
Copy link
Member Author

If I have code and result as follows, I want to know if it is the expected behavior. @ReneWerner87

package main

import (
	"github.com/gofiber/fiber/v2"
)

func main() {

	app := fiber.New(fiber.Config{
		StrictRouting: true,
	})

	app.Use("/foo", func(c *fiber.Ctx) error {
		return c.SendString(c.Path())
	})

	app.Listen(":8888")
}

then request it:

$ curl 0.0.0.0:8888/foo
/foo
$ curl 0.0.0.0:8888/foo/
/foo/

@ReneWerner87
Copy link
Member

If I have code and result as follows, I want to know if it is the expected behavior. @ReneWerner87

package main

import (
	"github.com/gofiber/fiber/v2"
)

func main() {

	app := fiber.New(fiber.Config{
		StrictRouting: true,
	})

	app.Use("/foo", func(c *fiber.Ctx) error {
		return c.SendString(c.Path())
	})

	app.Listen(":8888")
}

then request it:

$ curl 0.0.0.0:8888/foo
/foo
$ curl 0.0.0.0:8888/foo/
/foo/

Yes, because you use "app.Use" and it matches the prefix and not strict the whole path

Pls test it with "app.Get"

@wangjq4214 wangjq4214 marked this pull request as ready for review August 30, 2022 13:16
@ReneWerner87 ReneWerner87 merged commit e8c93e6 into gofiber:master Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 [Bug]: Group route / isn't handled properly in StrictRouting mode
2 participants