-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove the query string from links to xeets (#303)
* Remove query string from xeet links * Move formatter test suite next to formatter itself * Write test suite for URL normalization
- Loading branch information
Showing
3 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
assets/chat/js/formatters.test.js → ...tters/AmazonAssociatesTagInjector.test.js
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,29 @@ | ||
import UrlFormatter from './UrlFormatter'; | ||
|
||
const urlFormatter = new UrlFormatter(); | ||
|
||
describe('Normalizing URLs', () => { | ||
test('Remove the query string from a tweet URL', () => { | ||
expect( | ||
urlFormatter.normalizeUrl('https://twitter.com/jack/status/20?lang=en') | ||
).toBe('https://twitter.com/jack/status/20'); | ||
}); | ||
|
||
test('Remove the query string from a xeet URL', () => { | ||
expect( | ||
urlFormatter.normalizeUrl('https://x.com/jack/status/20?lang=en') | ||
).toBe('https://x.com/jack/status/20'); | ||
}); | ||
|
||
test("Don't modify a URL to a tweet that doesn't contain a query string", () => { | ||
expect(urlFormatter.normalizeUrl('https://x.com/jack/status/20')).toBe( | ||
'https://x.com/jack/status/20' | ||
); | ||
}); | ||
|
||
test("Don't modify a URL that isn't Twitter or X", () => { | ||
expect( | ||
urlFormatter.normalizeUrl('https://www.twitch.tv/search?term=vtuber') | ||
).toBe('https://www.twitch.tv/search?term=vtuber'); | ||
}); | ||
}); |