@bufferapp/publish-utils
Advanced tools
Comparing version 0.5.35 to 0.6.0
const twitter = require('./twitter.text'); | ||
const makeUnicodeAwareIndexUnaware = (str, i) => Array.from(str).slice(0, i).join('').length; | ||
module.exports = { | ||
parseFacebookEntities: (postText, entities) => { | ||
if (!entities) return []; | ||
return entities.map(({ url, text, indices }) => ({ | ||
displayString: text, | ||
indices: [ | ||
makeUnicodeAwareIndexUnaware(postText, indices[0]), | ||
makeUnicodeAwareIndexUnaware(postText, indices[1]), | ||
], | ||
rawString: text, | ||
url, | ||
})); | ||
}, | ||
parseTwitterLinks: text => | ||
@@ -5,0 +20,0 @@ twitter.extractEntitiesWithIndices(text) |
{ | ||
"name": "@bufferapp/publish-utils", | ||
"version": "0.5.35", | ||
"version": "0.6.0", | ||
"description": "Misc. utils for dates, parsing, etc.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
const { getDateString } = require('./date'); | ||
const { parseTwitterLinks } = require('./linkParsing'); | ||
const { | ||
parseTwitterLinks, | ||
parseFacebookEntities, | ||
} = require('./linkParsing'); | ||
@@ -75,2 +78,10 @@ const getImageUrls = (post) => { | ||
} | ||
const canHaveLinks = post.profile_service === 'twitter' || post.profile_service === 'facebook'; | ||
const links = | ||
parseTwitterLinks(text) | ||
.concat(post.profile_service === 'facebook' ? parseFacebookEntities(text, post.entities) : []) | ||
.sort(({ indices: [startIdxA] }, { indices: [startIdxB] }) => startIdxA - startIdxB); | ||
return { | ||
@@ -84,3 +95,3 @@ day: post.day, | ||
imageUrls: getImageUrls(post), | ||
links: parseTwitterLinks(text), | ||
links: canHaveLinks ? links : [], | ||
profileTimezone: post.profile_timezone, | ||
@@ -95,3 +106,3 @@ linkAttachment: { | ||
retweetComment, | ||
retweetCommentLinks: parseTwitterLinks(retweetComment), | ||
retweetCommentLinks: canHaveLinks ? links : [], | ||
retweetProfile: getRetweetProfileInfo(post), | ||
@@ -98,0 +109,0 @@ sent: post.status === 'sent', |
@@ -7,3 +7,4 @@ module.exports = profile => ({ | ||
handle: profile.service_username, | ||
notifications: profile.counts.pending, | ||
pendingCount: profile.counts.pending, | ||
sentCount: profile.counts.sent, | ||
timezone: profile.timezone, | ||
@@ -10,0 +11,0 @@ schedules: profile.schedules, |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
159828
1439
0