Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
validateRequest(request) {
let imageUrl = request.query.url;
imageUrl = imageUrl ? imageUrl.trim() : '';
// Require url
if (!imageUrl) {
return new Error(this.errors.url_missing);
}
// Check valid url
if (!validUrl.isHttpUri(imageUrl) && !validUrl.isHttpsUri(imageUrl)) {
return new Error(this.errors.url_invalid);
}
// Get extension
let extension = this.getUrlExtension(imageUrl);
if (this.validExtensions.indexOf(extension) === -1) {
return new Error(this.errors.url_image_invalid);
}
return true;
}
validate: (value) => {
return UrlValidator.isHttpUri(value) || UrlValidator.isHttpsUri(value);
},
error: 'The URL must be valid and be https:// or http://',
async function processConnectEndpointArgs(config) {
if (args.stdin) {
Object.assign(args, JSON.parse(await getStdin()));
}
else if (args.input != null) {
Object.assign(args, JSON.parse(await txtfile.read(args.input)));
}
if (!args.endpoint) {
throw new Error('missing --endpoint');
}
if (!validurl.isHttpUri(args.endpoint) && !validurl.isHttpsUri(args.endpoint)) {
throw new Error(`--endpoint ${args.endpoint} is not a valid url`);
}
if (args.appId && !utils_1.uuidValidate(args.appId)) {
throw new Error('--appId is not valid');
}
if (args.appPassword && args.appPassword.length == 0) {
throw new Error('zero length --appPassword');
}
if (!args.hasOwnProperty('name')) {
if (args.appId) {
args.name = `${args.endpoint} - ${args.appId}`;
}
else {
args.name = args.endpoint;
}
}
export const isUrlSameProtocol = (url: string, protocol: string) => {
let isHttp = protocol === PROTOCOLS.HTTP && !!isHttpUri(url);
let isHttps = protocol === PROTOCOLS.HTTPS && !!isHttpsUri(url);
return isHttp || isHttps;
};
function isValidURL(testURL) {
return Boolean(isHttpUri(testURL) || isHttpsUri(testURL));
}
function prepareUrl(url) {
url = _.clone(url);
if (_.isString(url)) {
url = setHttp(url);
if (!validUrl.isHttpUri(url) && !validUrl.isHttpsUri(url)) {
throw Error('uri is not a valid http uri ' + url);
}
url = parseUrl(url);
}
return url;
}
value => (
!!((validUrl.isHttpUri(value) || validUrl.isHttpsUri(value)))
),
)
validate: v => validUrl.isHttpsUri(v) || validUrl.isHttpUri(v),
validationMsg: i18n => i18n.gettext("`url` must be properly-" + "formatted URL.")
if (!args.subscriptionId || !utils_1.uuidValidate(args.subscriptionId))
throw new Error('Bad or missing --subscriptionId');
if (!args.resourceGroup || args.resourceGroup.length == 0)
throw new Error('Bad or missing --resourceGroup for registered bot');
let services = [];
let service = new botframework_config_1.BotService({
name: args.hasOwnProperty('name') ? args.name : args.serviceName,
serviceName: args.serviceName,
tenantId: args.tenantId,
subscriptionId: args.subscriptionId,
resourceGroup: args.resourceGroup
});
config.connectService(service);
services.push(service);
if (args.endpoint) {
if (!args.endpoint || !(validurl.isHttpUri(args.endpoint) || !validurl.isHttpsUri(args.endpoint)))
throw new Error('Bad or missing --endpoint');
if (!args.appId || !utils_1.uuidValidate(args.appId))
throw new Error('Bad or missing --appId');
if (!args.appPassword || args.appPassword.length == 0)
throw new Error('Bad or missing --appPassword');
let endpointService = new botframework_config_1.EndpointService({
type: botframework_config_1.ServiceTypes.Endpoint,
name: args.hasOwnProperty('name') ? args.name : args.endpoint,
appId: args.appId,
appPassword: args.appPassword,
endpoint: args.endpoint
});
config.connectService(endpointService);
services.push(endpointService);
}
await config.save(args.secret);