Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
words = [text];
if (text.indexOf(' ') > -1) {
words = text.split(' ');
}
// add html links
i = words.length;
while (x < i) {
var cn = options.className,
word = utils.trim(words[x]);
// the . is not need for valid url, but is inforced here
if (word.indexOf('http:') === 0 || word.indexOf('https:') === 0 && word.indexOf('.') > 0) {
// check url is valid
if (validUrl.isUri(word)) {
if (!out.url) {
out.url = [];
}
expanded = getExpandedUrl(word, options);
var address = word;
if (expanded) {
address = expanded;
out.url.push({
match: word,
expanded: expanded
});
} else {
out.url.push({
match: word
});
}
formatRedditUrl (url) {
if (!validUrl.isUri(url)) {
throw new Error('Valid url is required')
}
let parsed = parse(url)
if (!parsed.hostname === 'www.reddit.com') {
throw new Error('Url has to use www.reddit.com as host')
}
if (url.endsWith('.json')) {
return url
} else if (url.endsWith('/')) {
let urlArr = url.split('/')
urlArr.pop() // removes the enpty
return `${urlArr.join('/')}.json`
} else {
throw new Error('Url is not correct format for a Reddit proof')
const isGlobURI = (s) => (/^\/.*\/$/).test(s) || Boolean(validUrl.isUri(s)) || (isString(s) && s.includes('*'));
const isIPv4 = (s) => {
async getRedditData (url) {
let rUrl = this.formatRedditUrl(url)
if (!validUrl.isUri(rUrl)) {
throw new Error('Valid url is required')
}
try {
return await fetch(rUrl)
.then((response) => {
return response.json();
})
} catch (ex) {
console.error(ex)
return null
}
}
const isValidConnect = (v) => isIPv4(v) || isUri(v) || /[\w-]+(\.[\w-]+)+/.test(v) || v === '*';
if (!val) {
const isValidConnect = (v) => isIPv4(v) || isUri(v) || /[\w-]+(\.[\w-]+)+/.test(v) || v === '*';
if (!val) {
export function verify (args) {
const config = getConfig();
const toValidate = validUrl.isUri(args.PACT_FILE) ? args.PACT_FILE : path.resolve(process.cwd(), args.PACT_FILE);
const opts = {
pactUrls: [toValidate],
providerBaseUrl: args.provider_base_url,
providerStatesSetupUrl: args.states_setup_url,
};
if (config.brokerUser.trim() !== '') {
Object.assign(opts, {
pactBrokerUsername: config.brokerUser,
pactBrokerPassword: config.brokerPassword,
});
}
pact.verifyPacts(opts).then((pactObject) => {
log('=================================================================================');
}
var foundCategory = false;
for (var i in dappCategory) {
if (dappCategory[i] == dapp.category) {
foundCategory = true;
break;
}
}
if (!foundCategory) {
return setImmediate(cb, "Unknown dapp category");
}
if (dapp.icon) {
if (!valid_url.isUri(dapp.icon)) {
return setImmediate(cb, "Invalid icon link");
}
var length = dapp.icon.length;
if (
dapp.icon.indexOf('.png') != length - 4 &&
dapp.icon.indexOf('.jpg') != length - 4 &&
dapp.icon.indexOf('.jpeg') != length - 5
) {
return setImmediate(cb, "Invalid icon file type")
}
if (dapp.icon.length > 160) {
return setImmediate(cb, "Dapp icon url is too long. Maximum is 160 characters");
}