Skip to content

Commit

Permalink
Merge pull request #401 from dsuppiger/update_twitter_text_length
Browse files Browse the repository at this point in the history
Twitter: Updated max text length
  • Loading branch information
pmb0 authored Sep 19, 2023
2 parents b45b0e8 + b3ba9d7 commit 1a4617c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/js/services/twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ module.exports = function(shariff) {

var title = shariff.getTitle()

// 120 is the max character count left after twitters automatic url shortening with t.co
shareUrl.query.text = abbreviateText(title, 120)
shareUrl.query.url = shariff.getURL()
if (shariff.options.twitterVia !== null) {
shareUrl.query.via = shariff.options.twitterVia
}
// From Twitters documentation (May 2021):
// The length of your passed Tweet text should not exceed 280 characters
// when combined with any passed hashtags, via, or url parameters.
var remainingTextLength = (280 - (shareUrl.query.via || '').length - (shareUrl.query.url || '').length)
shareUrl.query.text = abbreviateText(title, remainingTextLength)

delete shareUrl.search

return {
Expand Down

0 comments on commit 1a4617c

Please sign in to comment.