Skip to content

Commit 2d09a1c

Browse files
Added support for X in social-urls (#512)
ref https://linear.app/ghost/issue/PLG-415/support-using-x-in-place-of-twitter - Added X as an alias so that it can be used without breaking compatibility with Twitter
1 parent c81809a commit 2d09a1c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

packages/social-urls/lib/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ module.exports.twitter = function twitter(username) {
77
return 'https://x.com/' + username.replace(/^@/, '');
88
};
99

10+
// Alias for twitter to support X
11+
module.exports.x = module.exports.twitter;
12+
1013
/**
1114
* @param {string} username
1215
* @returns {string}

packages/social-urls/test/urls.test.js

+14
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ describe('lib/social: urls', function () {
1111
should.exist(social.twitter);
1212
});
1313

14+
it('should have a x url function', function () {
15+
should.exist(social.x);
16+
});
17+
1418
it('should have a facebook url function', function () {
1519
should.exist(social.facebook);
1620
});
@@ -53,6 +57,16 @@ describe('lib/social: urls', function () {
5357
});
5458
});
5559

60+
describe('x', function () {
61+
it('should return a correct concatenated URL', function () {
62+
social.x('@myusername').should.eql('https://x.com/myusername');
63+
});
64+
65+
it('should return a url without an @ sign if one is provided', function () {
66+
social.x('myusername').should.eql('https://x.com/myusername');
67+
});
68+
});
69+
5670
describe('facebook', function () {
5771
it('should return a correct concatenated URL', function () {
5872
social.facebook('myusername').should.eql('https://www.facebook.com/myusername');

0 commit comments

Comments
 (0)