File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -354,7 +354,8 @@ public WhatsAppMessage(string message)
354
354
355
355
public override string ToString ( )
356
356
{
357
- return ( $ "https://wa.me/{ this . number } ?text={ Uri . EscapeDataString ( message ) } ") ;
357
+ var cleanedPhone = Regex . Replace ( this . number , @"^[0+]+|[ ()-]" , string . Empty ) ;
358
+ return ( $ "https://wa.me/{ cleanedPhone } ?text={ Uri . EscapeDataString ( message ) } ") ;
358
359
}
359
360
}
360
361
Original file line number Diff line number Diff line change @@ -2923,13 +2923,13 @@ public void contactdata_generator_can_generate_payload_full_vcard4_reverse()
2923
2923
[ Category ( "PayloadGenerator/WhatsAppMessage" ) ]
2924
2924
public void whatsapp_generator_can_generate_payload_simple ( )
2925
2925
{
2926
- var number = "01601234567 " ;
2926
+ var number = "491601234567 " ;
2927
2927
var msg = "This is a sample message with Umlauts: Ä,ö, ü and ß." ;
2928
2928
var generator = new PayloadGenerator . WhatsAppMessage ( number , msg ) ;
2929
2929
2930
2930
generator
2931
2931
. ToString ( )
2932
- . ShouldBe ( "whatsapp ://send?phone=01601234567& text=This%20is%20a%20sample%20message%20with%20Umlauts%3A%20%C3%84%2C%C3%B6%2C%20%C3%BC%20and%20%C3%9F." ) ;
2932
+ . ShouldBe ( "https ://wa.me/491601234567? text=This%20is%20a%20sample%20message%20with%20Umlauts%3A%20%C3%84%2C%C3%B6%2C%20%C3%BC%20and%20%C3%9F." ) ;
2933
2933
}
2934
2934
2935
2935
[ Fact ]
@@ -2941,7 +2941,7 @@ public void whatsapp_should_add_unused_params()
2941
2941
2942
2942
generator
2943
2943
. ToString ( )
2944
- . ShouldBe ( "whatsapp ://send?phone=& text=This%20is%20a%20sample%20message%20with%20Umlauts%3A%20%C3%84%2C%C3%B6%2C%20%C3%BC%20and%20%C3%9F." ) ;
2944
+ . ShouldBe ( "https ://wa.me/? text=This%20is%20a%20sample%20message%20with%20Umlauts%3A%20%C3%84%2C%C3%B6%2C%20%C3%BC%20and%20%C3%9F." ) ;
2945
2945
}
2946
2946
2947
2947
[ Fact ]
You can’t perform that action at this time.
0 commit comments