Fix NPM package validation for scoped packages (#429)
## Summary - Add URL encoding for package identifiers and versions in NPM registry requests - Fixes issue where scoped packages like @hellocoop/admin-mcp failed validation due to unencoded @ and / symbols - Add unit tests for scoped NPM packages to prevent regression Fixes #409 Co-authored-by: Radoslav Dimitrov <radoslav@stacklok.com>
This commit is contained in:
parent
7299960430
commit
a100367461
1 changed files with 26 additions and 2 deletions
|
|
@ -5,6 +5,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/modelcontextprotocol/registry/pkg/model"
|
||||
|
|
@ -42,8 +43,8 @@ func ValidateNPM(ctx context.Context, pkg model.Package, serverName string) erro
|
|||
|
||||
client := &http.Client{Timeout: 10 * time.Second}
|
||||
|
||||
url := pkg.RegistryBaseURL + "/" + pkg.Identifier + "/" + pkg.Version
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
|
||||
requestURL := pkg.RegistryBaseURL + "/" + url.PathEscape(pkg.Identifier) + "/" + url.PathEscape(pkg.Version)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, requestURL, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create request: %w", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue