mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-02 05:41:10 -08:00
fix(language): version url templates fix
dotnet + node + npm + php + python url helper: returns plain text if url is empty instead of failing
This commit is contained in:
parent
19b8cf2cf8
commit
0d9eaa2a09
|
@ -29,7 +29,7 @@ func (d *Dotnet) Init(props properties.Properties, env environment.Environment)
|
|||
`(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?))`,
|
||||
},
|
||||
},
|
||||
versionURLTemplate: "https://github.com/dotnet/core/blob/master/release-notes/{{ .Major }}.{{ .Minor }}/{{ .Major }}.{{ .Minor }}.{{ .Patch }}/{{ .Major }}.{{ .Minor }}.{{ .Patch }}.md", // nolint: lll
|
||||
versionURLTemplate: "https://github.com/dotnet/core/blob/master/release-notes/{{ .Major }}.{{ .Minor }}/{{ .Major }}.{{ .Minor }}.{{ substr 0 1 .Patch }}/{{ .Major }}.{{ .Minor }}.{{ substr 0 1 .Patch }}.md", // nolint: lll
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ func (n *Node) Init(props properties.Properties, env environment.Environment) {
|
|||
regex: `(?:v(?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+))))`,
|
||||
},
|
||||
},
|
||||
versionURLTemplate: "[%[1]s](https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V%[2]s.md#%[1]s)",
|
||||
versionURLTemplate: "https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V{{ .Major }}.md#{{ .Full }}",
|
||||
matchesVersionFile: n.matchesVersionFile,
|
||||
loadContext: n.loadContext,
|
||||
}
|
||||
|
|
|
@ -29,6 +29,6 @@ func (n *Npm) Init(props properties.Properties, env environment.Environment) {
|
|||
regex: `(?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+)))`,
|
||||
},
|
||||
},
|
||||
versionURLTemplate: "https://github.com/npm/npm/releases/tag/v{{ .Full }}",
|
||||
versionURLTemplate: "https://github.com/npm/cli/releases/tag/v{{ .Full }}",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ func (p *Php) Init(props properties.Properties, env environment.Environment) {
|
|||
regex: `(?:PHP (?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+))))`,
|
||||
},
|
||||
},
|
||||
versionURLTemplate: "[%[1]s](https://www.php.net/ChangeLog-%[2]s.php#PHP_%[2]s_%[3]s)",
|
||||
versionURLTemplate: "https://www.php.net/ChangeLog-{{ .Major }}.php#PHP_{{ .Major }}_{{ .Minor }}",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ func (p *Python) Init(props properties.Properties, env environment.Environment)
|
|||
regex: `(?:Python (?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+))))`,
|
||||
},
|
||||
},
|
||||
versionURLTemplate: "[%s](https://www.python.org/downloads/release/python-%s%s%s/)",
|
||||
versionURLTemplate: "https://docs.python.org/release/{{ .Major }}.{{ .Minor }}.{{ .Patch }}/whatsnew/changelog.html#python-{{ .Major }}-{{ .Minor }}-{{ .Patch }}",
|
||||
displayMode: props.GetString(DisplayMode, DisplayModeEnvironment),
|
||||
homeEnabled: props.GetBool(HomeEnabled, true),
|
||||
}
|
||||
|
|
|
@ -5,7 +5,11 @@ import (
|
|||
link "net/url"
|
||||
)
|
||||
|
||||
// url builds an hyperlink if url is not empty, otherwise returns the text only
|
||||
func url(text, url string) (string, error) {
|
||||
if url == "" {
|
||||
return text, nil
|
||||
}
|
||||
_, err := link.ParseRequestURI(url)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
|
Loading…
Reference in a new issue