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

Function candidatePaths

internal/attachments/references.go:425–436  ·  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

423// "<./my file.png>" or "./my%20file.png" to parse at all, which is also why a
424// space inside the brackets belongs to the name and is kept.
425func candidatePaths(dest string) []string {
426 out := []string{dest}
427 if unescaped := unescapePunctuation(dest); unescaped != dest {
428 out = append(out, unescaped)
429 }
430 for _, s := range append([]string{}, out...) {
431 if decoded, err := url.PathUnescape(s); err == nil && decoded != s {
432 out = append(out, decoded)
433 }
434 }
435 return out
436}
437
438// comparableDestination reduces a destination goldmark reported to the single
439// 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