Skip to content

Commit 46c4ca1

Browse files
committed
fix newurl
1 parent b633980 commit 46c4ca1

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

generator/helpers.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,14 @@ func FixAcronyms(content []byte) []byte {
9999
regexEnd := regexp.MustCompile(`([a-z])(` + a.pattern + `)$`)
100100

101101
// For Id, exclude '(' to preserve method calls like res.LastInsertId()
102+
// For Url, exclude ':' and ',' to preserve struct field names like NewUrl, OldUrl
102103
nonLetterClass := `[^A-Za-z]`
103-
if a.pattern == "Id" {
104+
105+
switch a.pattern {
106+
case "Id":
104107
nonLetterClass = `[^A-Za-z(]`
108+
case "Url":
109+
nonLetterClass = `[^A-Za-z:,]`
105110
}
106111

107112
regexNonLetter := regexp.MustCompile(`([a-z])(` + a.pattern + `)(` + nonLetterClass + `)`)

generator/helpers_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,14 @@ func TestFixAcronyms(t *testing.T) {
125125
expected: "userID = 123",
126126
},
127127
{
128-
name: "imageUrl in struct literal should become imageURL",
129-
input: "imageUrl: \"https://example.com\"",
130-
expected: "imageURL: \"https://example.com\"",
128+
name: "NewUrl in struct literal should remain NewUrl",
129+
input: "NewUrl: \"value\"",
130+
expected: "NewUrl: \"value\"",
131+
},
132+
{
133+
name: "OldUrl in struct literal should remain OldUrl",
134+
input: "OldUrl: \"value\"",
135+
expected: "OldUrl: \"value\"",
131136
},
132137
{
133138
name: "profileUrl in assignment should become profileURL",

0 commit comments

Comments
 (0)