Skip to content

Commit

Permalink
Merge 7b23ce9 into ba63df0
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Apr 2, 2024
2 parents ba63df0 + 7b23ce9 commit 0049e16
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 5 additions & 3 deletions loader/cdnjs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type cdnjsEnvelope struct {
}
}

func cdnjs(logger logrus.FieldLogger, path string, parts []string) (string, error) {
func cdnjs(logger logrus.FieldLogger, specifier string, parts []string) (string, error) {
name := parts[0]
version := parts[1]
filename := parts[2]
Expand Down Expand Up @@ -56,7 +56,7 @@ func cdnjs(logger logrus.FieldLogger, path string, parts []string) (string, erro
if len(ver.Files) == 0 {
return "",
fmt.Errorf("cdnjs: no files for version %s of %s, this is a problem with the library or cdnjs not k6",
version, path)
version, specifier)
}
backupFilename = ver.Files[0]
for _, file := range ver.Files {
Expand All @@ -70,5 +70,7 @@ func cdnjs(logger logrus.FieldLogger, path string, parts []string) (string, erro
}
}

return "https://cdnjs.cloudflare.com/ajax/libs/" + name + "/" + version + "/" + filename, nil
realURL := "https://cdnjs.cloudflare.com/ajax/libs/" + name + "/" + version + "/" + filename
logger.Warnf(magicURLsDeprecationWarning, specifier, "cdnjs", realURL)
return realURL, nil
}
9 changes: 7 additions & 2 deletions loader/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ package loader

import "github.com/sirupsen/logrus"

func github(_ logrus.FieldLogger, _ string, parts []string) (string, error) {
func github(logger logrus.FieldLogger, specifier string, parts []string) (string, error) {
username := parts[0]
repo := parts[1]
filepath := parts[2]
return "https://raw.githubusercontent.com/" + username + "/" + repo + "/master/" + filepath, nil
realURL := "https://raw.githubusercontent.com/" + username + "/" + repo + "/master/" + filepath
logger.Warnf(magicURLsDeprecationWarning, specifier, "github", realURL)
return realURL, nil
}

const magicURLsDeprecationWarning = "Specifier %q resolved to use a non-conventional %s loader. " +
"That loader is deprecated and will be removed in v0.53.0. Please use the real URL %q instead."

0 comments on commit 0049e16

Please sign in to comment.