mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-21 02:55:37 -08:00
parent
6824a0a350
commit
ae671c711d
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"errors"
|
||||
"oh-my-posh/environment"
|
||||
"oh-my-posh/regex"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
@ -82,15 +83,16 @@ func (t *Text) cleanTemplate() {
|
|||
}
|
||||
|
||||
knownVariable := func(variable string) bool {
|
||||
if variable == "." {
|
||||
return true
|
||||
}
|
||||
variable = strings.TrimPrefix(variable, ".")
|
||||
splitted := strings.Split(variable, ".")
|
||||
if len(splitted) == 0 {
|
||||
return false
|
||||
return true
|
||||
}
|
||||
variable = splitted[0]
|
||||
// check if alphanumeric
|
||||
if !regex.MatchString(`^[a-zA-Z0-9]+$`, variable) {
|
||||
return true
|
||||
}
|
||||
for _, b := range knownVariables {
|
||||
if variable == b {
|
||||
return true
|
||||
|
|
|
@ -225,6 +225,11 @@ func TestCleanTemplate(t *testing.T) {
|
|||
Expected string
|
||||
Template string
|
||||
}{
|
||||
{
|
||||
Case: "Literal dots",
|
||||
Expected: " ... ",
|
||||
Template: " ... ",
|
||||
},
|
||||
{
|
||||
Case: "Literal dot",
|
||||
Expected: "hello . what's up",
|
||||
|
|
Loading…
Reference in a new issue