Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Lyse
tt
Commits
d0ed95be
Commit
d0ed95be
authored
Feb 06, 2021
by
Lysander Trischler
Browse files
Support tilde in URLs
parent
9591e307
Changes
2
Hide whitespace changes
Inline
Side-by-side
useragent/useragent.go
View file @
d0ed95be
...
...
@@ -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+)\)`
)
...
...
useragent/useragent_test.go
View file @
d0ed95be
...
...
@@ -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"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment