From 257bd7ea761b54d54b9b235ee2b154ece9efaba5 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 28 May 2023 03:17:53 +0400 Subject: [PATCH] Check if param names differ. --- httpr.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/httpr.go b/httpr.go index 18d2185..d36908d 100644 --- a/httpr.go +++ b/httpr.go @@ -114,6 +114,14 @@ outer: for _, child := range curNode.children { firstChar := path[i+1][0] if (firstChar == ':' || firstChar == '*') && firstChar == child.endpoint[0] { + // Do not allow different param names, because only the first one + // is saved, so a param won't be available by a new name. + // + // I am not the one to judge, but it is a little strange to + // expect different types of param in one place. + if path[i+1] != child.endpoint { + return errors.New("param names " + path[i+1] + " and " + child.endpoint + " are differ") + } curNode = child continue outer }