MCPcopy Create free account
hub / github.com/exercism/cli / relativePath

Method relativePath

cmd/download.go:329–345  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

327}
328
329func (sf solutionFile) relativePath() string {
330 file := sf.path
331
332 // Work around a path bug due to an early design decision (later reversed) to
333 // allow numeric suffixes for exercise directories, letting people have
334 // multiple parallel versions of an exercise.
335 pattern := fmt.Sprintf(`\A.*[/\\]%s-\d*/`, sf.slug)
336 rgxNumericSuffix := regexp.MustCompile(pattern)
337 if rgxNumericSuffix.MatchString(sf.path) {
338 file = string(rgxNumericSuffix.ReplaceAll([]byte(sf.path), []byte("")))
339 }
340
341 // Rewrite paths submitted with an older, buggy client where the Windows path is being treated as part of the filename.
342 file = strings.Replace(file, "\\", "/", -1)
343
344 return filepath.FromSlash(file)
345}
346
347func setupDownloadFlags(flags *pflag.FlagSet) {
348 flags.StringP("uuid", "u", "", "the solution UUID")

Callers 2

TestSolutionFileFunction · 0.95
runDownloadFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestSolutionFileFunction · 0.76