go-forge/params.go
Snider 768c547a47 feat: path parameter resolution with URL encoding
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 15:23:07 +00:00

18 lines
421 B
Go

package forge
import (
"net/url"
"strings"
)
// Params maps path variable names to values.
// Example: Params{"owner": "core", "repo": "go-forge"}
type Params map[string]string
// ResolvePath substitutes {placeholders} in path with values from params.
func ResolvePath(path string, params Params) string {
for k, v := range params {
path = strings.ReplaceAll(path, "{"+k+"}", url.PathEscape(v))
}
return path
}