Commit d0ed95be authored by Lysander Trischler's avatar Lysander Trischler

Support tilde in URLs

parent 9591e307
......@@ -34,7 +34,7 @@ func ExtractUserAgentFromNginxAccessLog(line string) string {
return line[idx+1 : len(line)-1]
}
const uri = `[\w:/._?&=@-]+`
const uri = `[\w:/._?&=@~-]+`
var clientRegex = regexp.MustCompile(`(\w+)/([\w.@_/-]+)`)
var singleUserRegex = regexp.MustCompile(`\(\+(` + uri + `)[;,]\s*@(\w+)\)`)
......
......@@ -74,6 +74,17 @@ func TestParseUserAgent(t *testing.T) {
WhoFollowsURL: "",
},
},
{
name: "Single user client User-Agent with tilde in URL",
userAgent: "twtxt/1.2.3 (+http://ctrl-c.club/~jlj/public_html/tw.txt; @jlj)",
expected: UserAgent{
ClientName: "twtxt",
ClientVersion: "1.2.3",
TwtxtURLs: []string{"http://ctrl-c.club/~jlj/public_html/tw.txt"},
TwtxtNicks: []string{"jlj"},
WhoFollowsURL: "",
},
},
{
name: "Single user client User-Agent with comma instead of semicolon as separator",
userAgent: "twtxt/1.1 (+http://twtxt.xyz/u/reednj.txt, @reednj) twtxt.xyz/1.21",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment