-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: isASocialNetworkUrl() regex for summarize-cool-pages (#44)
- Loading branch information
Showing
5 changed files
with
58 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { isASocialNetworkUrl } from '../helpers/regex.helper'; | ||
|
||
describe('Helpers: Regex', () => { | ||
describe('Rule: isASocialNetworkUrl should regex correctly an url', () => { | ||
it('isASocialNetworkUrl() should return true when the url is a social network url', () => { | ||
const url = 'www.facebook.com/username'; | ||
const result = isASocialNetworkUrl(url); | ||
expect(result).toBe(true); | ||
}); | ||
it('isASocialNetworkUrl() should return false when the url is not a social network url', () => { | ||
const url = 'https://blog.richardekwonye.com/bezier-curves'; | ||
const result = isASocialNetworkUrl(url); | ||
expect(result).toBe(false); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const socialNetworksUrlRegex = new RegExp( | ||
'^(https?://)?(www.)?(facebook.com|fb.me|twitter.com|vxtwitter.com|instagram.com|linkedin.com|youtube.com|youtu.be|pinterest.com|snapchat.com|tiktok.com)/[a-zA-Z0-9.-/?=&#_]+$', | ||
); | ||
export const isASocialNetworkUrl = (url: string): boolean => { | ||
return socialNetworksUrlRegex.test(url); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters