-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed an error that occurred when an author name contains a string th…
…at is not suitable for JSON (#3638) * fix(pkg): Fixed an issue where wails new would throw an error if the author name contained non-JSON legal characters. * refactor(pkg): Incorporating coderabbit's suggestions * docs: write changelog.mdx * Escape using json package. Add tests. * Update test. --------- Co-authored-by: Lea O'Anthony <lea.anthony@gmail.com>
- Loading branch information
1 parent
fe9495d
commit 5b091db
Showing
3 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package git | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestEscapeName1(t *testing.T) { | ||
type args struct { | ||
str string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
wantErr bool | ||
}{ | ||
{ | ||
name: "Escape Apostrophe", | ||
args: args{ | ||
str: `John O'Keefe`, | ||
}, | ||
want: `John O'Keefe`, | ||
}, | ||
{ | ||
name: "Escape backslash", | ||
args: args{ | ||
str: `MYDOMAIN\USER`, | ||
}, | ||
want: `MYDOMAIN\\USER`, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := EscapeName(tt.args.str) | ||
if (err != nil) != tt.wantErr { | ||
t.Errorf("EscapeName() error = %v, wantErr %v", err, tt.wantErr) | ||
return | ||
} | ||
if got != tt.want { | ||
t.Errorf("EscapeName() got = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters