@tryghost/social-urls 0.1.45 → 0.1.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +5 -27
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -7,6 +7,9 @@ module.exports.twitter = function twitter(username) {
|
|
|
7
7
|
return 'https://x.com/' + username.replace(/^@/, '');
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
+
// Alias for twitter to support X
|
|
11
|
+
module.exports.x = module.exports.twitter;
|
|
12
|
+
|
|
10
13
|
/**
|
|
11
14
|
* @param {string} username
|
|
12
15
|
* @returns {string}
|
|
@@ -40,33 +43,8 @@ module.exports.bluesky = function bluesky(username) {
|
|
|
40
43
|
* @returns {string}
|
|
41
44
|
*/
|
|
42
45
|
module.exports.mastodon = function mastodon(username) {
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// Check if the input is in @username@instance format
|
|
47
|
-
if (username.includes('@') && !username.includes('/')) {
|
|
48
|
-
const [user, instance] = username.split('@');
|
|
49
|
-
return `https://${instance}/@${user}`;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// Check if the input is in instance/@username format
|
|
53
|
-
if (username.includes('/@')) {
|
|
54
|
-
return `https://${username}`;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Check if the input is in hostInstance/@username@userInstance format
|
|
58
|
-
if (username.includes('/@') && username.includes('@', username.indexOf('/@') + 1)) {
|
|
59
|
-
return `https://${username}`;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// If we have a simple instance/username format
|
|
63
|
-
if (username.includes('/')) {
|
|
64
|
-
const [instance, user] = username.split('/');
|
|
65
|
-
return `https://${instance}/@${user}`;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Default case: assume it's a local handle on the instance
|
|
69
|
-
return `https://${username}`;
|
|
46
|
+
// Mastodon stores full URL without https://, just prepend protocol
|
|
47
|
+
return 'https://' + username;
|
|
70
48
|
};
|
|
71
49
|
|
|
72
50
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/social-urls",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.47",
|
|
4
4
|
"repository": "https://github.com/TryGhost/SDK/tree/main/packages/social-urls",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"should": "13.2.3",
|
|
24
24
|
"sinon": "20.0.0"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "c69c4c3ad837302b4ff64bbef7dc6dd59150222e"
|
|
27
27
|
}
|