MCPcopy Create free account
hub / github.com/cli/cli / candidatePaths

Function candidatePaths

internal/attachments/references.go:388–399  ·  view source on GitHub ↗

candidatePaths returns the ways a destination could name a file on disk. goldmark reports the destination alone, without the angle brackets or the whitespace that separated it from the rest of the link, so what arrives is already the name. Backslash escapes and percent encoding survive, and either c

(dest string)

Source from the content-addressed store, hash-verified

386// "<./my file.png>" or "./my%20file.png" to parse at all, which is also why a
387// space inside the brackets belongs to the name and is kept.
388func candidatePaths(dest string) []string {
389 out := []string{dest}
390 if unescaped := unescapePunctuation(dest); unescaped != dest {
391 out = append(out, unescaped)
392 }
393 for _, s := range append([]string{}, out...) {
394 if decoded, err := url.PathUnescape(s); err == nil && decoded != s {
395 out = append(out, decoded)
396 }
397 }
398 return out
399}
400
401// comparableDestination reduces a destination goldmark reported to the single
402// form used to decide whether a run of source is the node it came from. Percent

Callers 1

Calls 1

unescapePunctuationFunction · 0.85

Tested by

no test coverage detected