From 8e9889d3e5b2874854832d1d882d124132546f49 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Sat, 27 Jun 2026 22:34:36 +0200 Subject: add package pathrouter --- pathrouter/utils.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 pathrouter/utils.go (limited to 'pathrouter/utils.go') diff --git a/pathrouter/utils.go b/pathrouter/utils.go new file mode 100644 index 0000000..e8704a7 --- /dev/null +++ b/pathrouter/utils.go @@ -0,0 +1,22 @@ +// SPDX-FileCopyrightText: 2026 Stefan Majewsky +// SPDX-License-Identifier: Apache-2.0 + +package pathrouter + +import ( + "fmt" + "net/url" +) + +func pathUnescape(in string) string { + out, err := url.PathUnescape(in) + if err != nil { + // defense in depth: should not fail because `in` was indirectly obtained from r.URL.EscapedPath() + panic(fmt.Sprintf("PathUnescape failed on %q: %s", in, err.Error())) + } + return out +} + +func increment(x int) int { + return x + 1 +} -- cgit v1.3.1