Skip to content

Added support for X in social-urls #512

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

Merged
merged 1 commit into from
Apr 28, 2025
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
3 changes: 3 additions & 0 deletions packages/social-urls/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ module.exports.twitter = function twitter(username) {
return 'https://x.com/' + username.replace(/^@/, '');
};

// Alias for twitter to support X
module.exports.x = module.exports.twitter;

/**
* @param {string} username
* @returns {string}
Expand Down
14 changes: 14 additions & 0 deletions packages/social-urls/test/urls.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ describe('lib/social: urls', function () {
should.exist(social.twitter);
});

it('should have a x url function', function () {
should.exist(social.x);
});

it('should have a facebook url function', function () {
should.exist(social.facebook);
});
Expand Down Expand Up @@ -53,6 +57,16 @@ describe('lib/social: urls', function () {
});
});

describe('x', function () {
it('should return a correct concatenated URL', function () {
social.x('@myusername').should.eql('https://x.com/myusername');
});

it('should return a url without an @ sign if one is provided', function () {
social.x('myusername').should.eql('https://x.com/myusername');
});
});

describe('facebook', function () {
it('should return a correct concatenated URL', function () {
social.facebook('myusername').should.eql('https://www.facebook.com/myusername');
Expand Down