Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
User.findOne({ username }, (findByUsernameErr, existingUsernameUser) => {
if (existingUsernameUser) {
const adj = friendlyWords.predicates[Math.floor(Math.random() * friendlyWords.predicates.length)];
username = slugify(`${username} ${adj}`);
}
// what if a username is already taken from the display name too?
// then, append a random friendly word?
if (existingEmailUser) {
existingEmailUser.email = existingEmailUser.email || primaryEmail;
existingEmailUser.google = profile._json.emails[0].value;
existingEmailUser.username = existingEmailUser.username || username;
existingEmailUser.tokens.push({ kind: 'google', accessToken });
existingEmailUser.name = existingEmailUser.name || profile._json.displayName;
existingEmailUser.verified = User.EmailConfirmation.Verified;
existingEmailUser.save((saveErr) => {
if (saveErr) {
console.log(saveErr);
}
done(null, existingEmailUser);
});
.trim()
.replace('\n', '<p>')
.replace(/\s+/g, ' ')
.replace(/<br>/g, '\n')
.replace(/</p><p>/g, '\n\n')
: null;
const duration = event.duration || 0.5; // in hours
const profile = speaker ? speakerLookup[slugify(speaker)] : undefined;
const isTalk = !!profile;
if (!date || (!title && !speaker)) {
return null;
}
return {
slug: slugify(`${title} ${getTime(date)}`),
title: title || speaker,
isTalk,
speaker: isTalk ? speaker : null,
profile,
company,
agenda,
date,
duration
};
})
.filter(Boolean);
</p>
buildUri() {
this.uri = slugify(this.title)
}
}
{categories.map(category => (
))}
async function addTags() {
let numOfTags = settings.tags;
const linkedTagsRatio = 0.2;
const topLevelRatio = 0.1;
let batch = Tags.initializeUnorderedBulkOp({useLegacyOps: true});
for (let i = 0; i < numOfTags; i++) {
const data = _.cloneDeep(tagTemplate);
data._id = randomID(10, "aA0");
data.name = `${faker.commerce.department()}-${randomID(4, 'aA0')}`;
data.slug = slugify(data.name);
data.createdAt = new Date();
data.updatedAt = new Date();
if (i === Math.round(numOfTags * topLevelRatio)) {
data.isTopLevel = true
tags.push(data._id);
}
batch.insert(data);
}
await batch.execute();
batch = Tags.initializeUnorderedBulkOp({useLegacyOps: true});
const linkedTags = numOfTags * linkedTagsRatio;
for (let i = 0; i < linkedTags; i++) {
const currentTag = tags[Math.floor(Math.random() * tags.length)]
const start = Math.floor(Math.random() * tags.length);
const len = Math.floor(Math.random() * 5);
const end = (start + len) > tags.length ? tags.length : (start + len)
async onSave () {
let mutation = createGql;
const variables = {
title: this.inputField,
languageKey: this.$store.state.lc.locale.toUpperCase(),
slug: slugify(this.inputField, { lower: true })
};
if (this.selected) {
variables.id = this.selected;
mutation = updateGql;
}
await this.mutateGql(
{
mutation,
variables,
refetchQueries: ['allArticleCategories']
},
this.selected ? 'updateArticleCategory' : 'createArticleCategory'
);
},
toggleShow () {
{(link.countries || []).map(code => {
const country = Countries.fromAlpha2Code(
code.toUpperCase()
);
return (
<span title="{country.name}">
{country.emoji}
</span>
);
})}
const Screenreader = ({ headline, speak, _body, _ID, _parseMD, _relativeURL }) => (
<div>
<div>
<a href="{`#${">#</a>
<h2>
{ headline }
</h2>
<div>
<div>
{ _parseMD( speak ) }
</div>
</div>
<div>
{ _body }
</div>
</div>
</div>
);
const { title } = this.state;
if (title === "") {
return;
}
const { dispatch, history, userId } = this.props;
const boardId = shortid.generate();
dispatch({
type: "ADD_BOARD",
payload: {
boardTitle: title,
boardId,
userId
}
});
const urlSlug = slugify(title, { lower: true });
history.push(`/b/${boardId}/${urlSlug}`);
this.setState({ isOpen: false, title: "" });
};
formattedTextNodes.forEach((node: FormattedNode, index: number) => {
const titleSlug = slugify(metaData.title, { lower: true });
content.push({
...metaData,
url,
urlWithHash: url + node.hash,
hash: node.hash,
textContent: node.textContent,
id: titleSlug,
objectID: `${titleSlug}_${index}`,
});
});