File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,8 +35,6 @@ github.com/googleapis/gax-go/v2 v2.15.0 h1:SyjDc1mGgZU5LncH8gimWo9lW1DtIfPibOG81
3535github.com/googleapis/gax-go/v2 v2.15.0 /go.mod h1:zVVkkxAQHa1RQpg9z2AUCMnKhi0Qld9rcmyfL1OZhoc =
3636github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0 =
3737github.com/joho/godotenv v1.5.1 /go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4 =
38- github.com/julwrites/BotPlatform v0.0.0-20220206144002-60e1b8060734 h1:U/z8aO/8zMpOzdR7kK9hnHfXber1fHa7FWlXGeuG3Yc =
39- github.com/julwrites/BotPlatform v0.0.0-20220206144002-60e1b8060734 /go.mod h1:RAVF1PibRuRYv1Z7VxNapzrikBrjtF48aFPCoCVnLpM =
4038github.com/julwrites/BotPlatform v0.0.0-20251128175347-656700b2e4d4 h1:NeEPkJt4VXvyb/zxggO9zFs9tAJ07iiht1lAkUL/ZNs =
4139github.com/julwrites/BotPlatform v0.0.0-20251128175347-656700b2e4d4 /go.mod h1:PZT+yPLr4MrricOGOhXwiJCurNcGj36fD1jZOwMiuIk =
4240github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE =
Original file line number Diff line number Diff line change @@ -55,11 +55,8 @@ func ParseNodesForPassage(node *html.Node) string {
5555 switch tag := child .Data ; tag {
5656 case "span" :
5757 childText := ParseNodesForPassage (child )
58- if len (childText ) > 0 {
59- parts = append (parts , childText )
60- parts = append (parts , "\n " )
61- } else {
62- parts = append (parts , child .Data )
58+ parts = append (parts , childText )
59+ if len (strings .TrimSpace (childText )) > 0 {
6360 parts = append (parts , "\n " )
6461 }
6562 case "sup" :
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ func TestParsePassageFromHtml(t *testing.T) {
102102
103103 t .Run ("HTML with spans" , func (t * testing.T ) {
104104 html := `<p><span>Line 1.</span><br><span> </span><span>Line 2.</span></p>`
105- expected := "Line 1.\n \n Line 2.\n "
105+ expected := "Line 1.\n \n Line 2."
106106 if got := ParsePassageFromHtml ("" , html , "" ); got != expected {
107107 t .Errorf ("ParsePassageFromHtml() = %v, want %v" , got , expected )
108108 }
Original file line number Diff line number Diff line change @@ -54,6 +54,11 @@ func GetUser(user def.UserData, project string) def.UserData {
5454 ctx := context .Background ()
5555 client := OpenClient (& ctx , project )
5656
57+ if client == nil {
58+ return user
59+ }
60+ defer client .Close ()
61+
5762 key := datastore .NameKey ("User" , user .Id , nil )
5863 var entity def.UserData
5964 err := client .Get (ctx , key , & entity )
@@ -74,6 +79,11 @@ func GetAllUsers(project string) []def.UserData {
7479 ctx := context .Background ()
7580 client := OpenClient (& ctx , project )
7681
82+ if client == nil {
83+ return []def.UserData {}
84+ }
85+ defer client .Close ()
86+
7787 var users []def.UserData
7888
7989 _ , err := client .GetAll (ctx , datastore .NewQuery ("User" ), & users )
@@ -93,6 +103,11 @@ func PushUser(user def.UserData, project string) bool {
93103 ctx := context .Background ()
94104 client := OpenClient (& ctx , project )
95105
106+ if client == nil {
107+ return false
108+ }
109+ defer client .Close ()
110+
96111 key := datastore .NameKey ("User" , user .Id , nil )
97112
98113 _ , err := client .Put (ctx , key , & user )
You can’t perform that action at this time.
0 commit comments