Skip to content

Commit

Permalink
fixed social links for Twitter and GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
bincyber committed Oct 4, 2024
1 parent a0e7708 commit 2ff61ef
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
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

0 comments on commit 2ff61ef

Please sign in to comment.