From bd5ce9b526897eee1644518716a17232b296e701 Mon Sep 17 00:00:00 2001 From: "Jorge Alberto Diaz Orozco (Akiel)" Date: Wed, 25 Sep 2024 21:12:37 +0200 Subject: [PATCH] Improve the regular expression so it can detect keys that are not in a new line --- main.go | 2 +- main_test.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index b8cd2ab..3843629 100644 --- a/main.go +++ b/main.go @@ -94,7 +94,7 @@ func reply(update tgbotapi.Update, bot *tgbotapi.BotAPI, reply string) { func findServers(input string) []string { servers := []string{} - r, err := regexp.Compile("\n+\\s*(ss://[A-Za-z0-9]+=*@.+:\\d+|ss://[A-Za-z0-9]+)") + r, err := regexp.Compile("(\n+\\s*|\\s+)(ss://[A-Za-z0-9]+=*@.+:\\d+|ss://[A-Za-z0-9]+)") if err != nil { log.Printf("error building RE %v", err) return nil diff --git a/main_test.go b/main_test.go index 0056e8c..06aae86 100644 --- a/main_test.go +++ b/main_test.go @@ -28,6 +28,8 @@ ss://YWVzLTI1Ni1nY206ZmFCQW9ENTRrODdVSkc3@54.36.174.181:2376#Britain504%20%28t.m ss://YWVzLTI1Ni1nY206S2l4THZLendqZWtHMDBybQ==@ak1394.free.www.outline.network:8080#www.outline.network%20(japan) vmess://eyJhZGQiOiIxMTYuMjAzLjczLjM0IiwiYWlkIjoiMCIsImFscG4iOiIiLCJob3N0IjoiZ29vZ2xlLmNvbSIsImlkIjoiMmFhYzc3ZGUtYjNlNC00MDE3LTg0NWMtY2ExMzgwZjJlOGQwIiwibmV0Ijoid3MiLCJwYXRoIjoiL3RlbGVncmFtLWlkLUBwcml2YXRldnBucyIsInBvcnQiOiI4MCIsInBzIjoiMTExNyhAT3V0bGluZV9WcG4pIiwic2N5IjoiYXV0byIsInNuaSI6IiIsInRscyI6IiIsInR5cGUiOiIiLCJ2IjoiMiJ9 vless://YWVzLTI1Ni1nY206ZmFCQW9ENTRrODdVSkc3@54.36.174.181:2376#Britain504%20%28t.me + +Страна: 🇳🇱 Нидерланды Срок действия: 3 дня Ключ: ss://Y2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTpUdTFSU2ZyakRoWGREaTlnWUYzeE9k@178.208.91.118:16942/?outline=1 ` expectedServers := []string{ "ss://YWVzLTI1Ni1nY206WTZSOXBBdHZ4eHptR0M@54.36.174.181:5002", @@ -37,9 +39,10 @@ vless://YWVzLTI1Ni1nY206ZmFCQW9ENTRrODdVSkc3@54.36.174.181:2376#Britain504%20%28 "ss://YWVzLTI1Ni1nY206ZmFCQW9ENTRrODdVSkc3@54.36.174.181:2376", "ss://YWVzLTI1Ni1nY206UENubkg2U1FTbmZvUzI3QDUuMzkuNzAuMTM4OjgwOTA", "ss://YWVzLTI1Ni1nY206S2l4THZLendqZWtHMDBybQ==@ak1394.free.www.outline.network:8080", + "ss://Y2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTpUdTFSU2ZyakRoWGREaTlnWUYzeE9k@178.208.91.118:16942", } servers := findServers(sample) - assert.Len(t, servers, 7) + assert.Len(t, servers, 8) assert.EqualValues(t, expectedServers, servers) }