Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
root.walkAtRules(/^media$/i, atRule => {
execall(/\((.*?)\)/g, atRule.params).forEach(mediaFeatureMatch => {
if (!isStandardSyntaxMediaFeature(mediaFeatureMatch.match)) { return }
const splitMediaFeature = mediaFeatureMatch.sub[0].trim().split(/\s+/)
if (splitMediaFeature.length === 1) { return }
// Ignore the last one
for (let i = 0, l = splitMediaFeature.length - 1; i < l; i++) {
const mediaFeaturePart = splitMediaFeature[i]
// This part is valid if it is punctuation,
// it ends with punctuation,
// the next part is punctuation,
// or the next part begins with punctuation
if (isPunctuation(mediaFeaturePart)) { continue }
if (endsWithPunctuation(mediaFeaturePart)) { continue }
const nextPart = splitMediaFeature[i + 1]
function check(source, node) {
// Get out quickly if there are no periods
if (source.indexOf(".") === -1) { return }
const sanitizedSource = blurComments(blurFunctionArguments(source, "url"))
const errors = execall(/\.\d*0+(?:\D|$)/g, sanitizedSource)
if (!errors.length) { return }
errors.forEach(error => {
report({
message: messages.rejected,
node,
index: error.index + error.match.length - 2,
result,
ruleName,
})
})
}
}
}
if (!isRegexp) {
regStr = value.replace(SPECIAL_CHAR_REG, (p) => {
return p === '\\' ? '\\\\' : `\\${p}`
})
}
if (isWholeWord) {
regStr = `\\b${regStr}\\b`
}
try {
// Add try catch expression because not all string can generate a valid RegExp. for example `\`.
SEARCH_REG = new RegExp(regStr, flag)
return execall(SEARCH_REG, text)
} catch (err) {
return []
}
}
for (const node of wpgqlNodes.values()) {
if (node.link) {
// create a pathname for the node using the WP permalink
node.path = urlToPath(node.link)
}
// here we're searching for file strings in our node
// we use this to download only the media items
// that are being used in posts
// this is important not only for downloading only used images
// but also for downloading images in post content
if (wpgqlNodesGroup.singular !== `mediaItems`) {
const nodeString = JSON.stringify(node)
const matches = execall(remoteFileRegex, nodeString)
if (matches.length) {
store.dispatch.imageNodes.addUrlMatches(matches)
}
}
await actions.createNode({
...node,
id: node.id,
parent: null,
internal: {
contentDigest: createContentDigest(node),
// @todo allow namespacing types with a plugin option. Default to `Wp`
type: `Wp${node.type}`,
},
})
function check(source, node) {
const sanitizedSource = blurComments(blurFunctionArguments(source, "url"))
const decimalNumberMatches = execall(/(\d*\.(\d+))/g, sanitizedSource)
if (!decimalNumberMatches.length) { return }
decimalNumberMatches.forEach(match => {
if (match.sub[1].length <= precision) { return }
report({
result,
ruleName,
node,
index: match.index,
message: messages.expected(parseFloat(match.sub[0]), precision),
})
})
}
}