Skip to content
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

Fixed social profile link for Twitter to accept x.com #51

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/chat-roulette/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ LABEL org.opencontainers.image.description="Chat Roulette for Slack"
COPY --from=build /src/bin/chat-roulette /chat-roulette
COPY --from=build /src/docs/examples/config.example.json /etc/config.json
USER 10000:10000
EXPOSE 8888
EXPOSE 8080
ENTRYPOINT [ "/chat-roulette", "-c", "/etc/config.json", "--migrate" ]
4 changes: 2 additions & 2 deletions internal/isx/is.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (
var (
socialDomains = map[string]string{
"facebook": `(?:(www\.)|(m\.))?facebook.com`,
"github": "github.com",
"github": `(?:(www\.))?github.com`,
"instagram": `(?:(www\.)|(m\.))?instagram.com`,
"linkedin": `(?:(www\.)|(m\.)|([a-z]{2}\.))?linkedin.com`,
"pinterest": `(?:(www\.))?pinterest.com`,
"snapchat": `(?:(www\.))?snapchat.com`,
"tiktok": `(?:(www\.)|(m\.))?tiktok.com`,
"twitter": `(?:(www\.)|(m\.))?twitter.com`,
"twitter": `(?:(www|m)\.)?(x\.com|twitter\.com)`,
"youtube": `(?:(www\.)|(m\.))?youtube.com`,
}
)
Expand Down
32 changes: 21 additions & 11 deletions internal/isx/is_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,26 +133,36 @@ func Test_ProfileType(t *testing.T) {

func Test_ValidateProfileLink(t *testing.T) {
type test struct {
name string
pType string
pLink string
isErr bool
}

tt := []test{
{"Twitter", "twitter.com/joe", false},
{"Instagram", "https://instagram.com/ahmed", false},
{"LinkedIn", "facebook.com/bincyber", true},
{"LinkedIn", "ca.linkedin.com/bincyber", false},
{"github", "https://github.com/bincyber", false},
{"twitter", "github.com/bincyber", true},
{"tiktok", "tiktok.com/@example", false},
{"pinterest", "p i n t e r e s t.com", true},
{"snapchat", "m.snapchat.com", true},
{"twitter", "twitter.com/", true},
{"Twitter", "Twitter", "twitter.com/joe", false},
{"X", "Twitter", "x.com/john", false},
{"mobile Twitter", "Twitter", "m.twitter.com/john", false},
{"mobile X", "Twitter", "m.x.com/john", false},
{"missing twitter username", "Twitter", "twitter.com/", true},
{"YouTube", "YouTube", "youtube.com/@mkbhd", false},
{"mobile YouTube", "YouTube", "m.youtube.com/@mkbhd", false},
{"invalid short YouTube", "YouTube", "youtu.be.com/@mkbhd", true},
{"Insta", "Instagram", "https://instagram.com/ahmed", false},
{"LinkedIn", "LinkedIn", "ca.linkedin.com/bincyber", false},
{"invalid LinkedIn", "LinkedIn", "linked.in/bincyber", true},
{"mismatch Facebook", "LinkedIn", "facebook.com/bincyber", true},
{"github", "github", "https://github.com/bincyber", false},
{"www github", "github", "www.github.com/bincyber", false},
{"invalid github", "GitHub", "m.github.com/bincyber", true},
{"mismatch GitHub", "LinkedIn", "github.com/bincyber", true},
{"TikTok", "TikTok", "tiktok.com/@example", false},
{"invalid pinterest", "Pinterest", "p i n t e r e s t.com", true},
{"invalid mobile snapchat", "Snapshot", "m.snapchat.com", true},
}

for _, tc := range tt {
t.Run(tc.pType, func(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
err := ValidProfileLink(tc.pType, tc.pLink)

if tc.isErr {
Expand Down
Loading