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>
import MarkdownIt from 'markdown-it'
import slugify from 'slugify'
import Renderer from './jsxRenderer'
import importsToCommonJS from './importsToCommonJS'
import jsx_inline from './jsx_inline'
import jsx_block from './jsx_block'
import text_with_newline from './text_with_newline'
slugify.extend({
'>': '',
'<': '',
'`': '',
})
const DEFAULT_FACTORIES = {
'wrapper': 'createFactory(\'div\')',
'codeBlock': '(props, children) => createElement("pre", props, createElement("code", { dangerouslySetInnerHTML: { __html: children || props.children } }))'
}
function mdJSX(md) {
// JSX should entirely replace embedded HTML.
md.inline.ruler.before('text', 'text_with_newline', text_with_newline);
md.inline.ruler.before('html_inline', 'jsx_inline', jsx_inline);
export function normalizeSlug (slug) {
if (!slug) return
// Remove certain replacements mapped by slugify
slugify.extend({
'|': null,
'%': null,
$: null
})
const slugified = slugify(slug, {
replacement: '-',
remove: /[*+=~.,<>(){}'"!?:;@#$%^&*|\\/[\]]/g,
lower: true
})
// Remove any trailing or leading hyphens, which slugify doesn't clean up
return slugified.replace(/^[-]+|[-]+$/g, '')
}
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>
);