-
Notifications
You must be signed in to change notification settings - Fork 4
fix: refactor relay URLs validation #1405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
fix: refactor relay URLs validation #1405
Conversation
rmb-sdk-go/peer/peer.go
Outdated
sort.Slice(validRelayURLs, func(i, j int) bool { | ||
return strings.ToLower(validRelayURLs[i]) < strings.ToLower(validRelayURLs[j]) | ||
slices.SortFunc(validRelayURLs, func(a, b *url.URL) int { | ||
return strings.Compare(a.Host, b.Host) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also we depend on hosts only ignoring ports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
for _, relayURL := range relayURLs { | ||
parsedURL, err := url.Parse(relayURL) | ||
parsedURL, err := url.Parse(strings.ToLower(relayURL)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we only lowercase Hostname
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is better imo since I convert to lower case once, hostname() will be inherently lowercase when I do sort or compact later
rmb-sdk-go/peer/peer.go
Outdated
sort.Slice(validRelayURLs, func(i, j int) bool { | ||
return strings.ToLower(validRelayURLs[i]) < strings.ToLower(validRelayURLs[j]) | ||
validRelayURLs = slices.CompactFunc(validRelayURLs, func(a, b *url.URL) bool { | ||
return a.Hostname() == b.Hostname() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't it ignoring ws
and wss
for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
Description
Small fix and refactor include:
Changes
Related Issues
More context
Checklist