How to use the valid-url.isHttpUri function in valid-url

To help you get started, we’ve selected a few valid-url examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lehoangduc / face-recognition-api / api / plugins / finder.js View on Github external
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;
  }
github AzureAD / passport-azure-ad / lib / validator.js View on Github external
validate: (value) => {
    return UrlValidator.isHttpUri(value) || UrlValidator.isHttpsUri(value);
  },
  error: 'The URL must be valid and be https:// or http://',
github microsoft / botbuilder-tools / packages / MSBot / bin / msbot-connect-endpoint.js View on Github external
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;
        }
    }
github mateeyow / sizzy-docker / src / utils / url-utils.js View on Github external
export const isUrlSameProtocol = (url: string, protocol: string) => {
  let isHttp = protocol === PROTOCOLS.HTTP && !!isHttpUri(url);
  let isHttps = protocol === PROTOCOLS.HTTPS && !!isHttpsUri(url);
  return isHttp || isHttps;
};
github mattermost / desktop / src / utils / util.js View on Github external
function isValidURL(testURL) {
  return Boolean(isHttpUri(testURL) || isHttpsUri(testURL));
}
github OptimalBits / redbird / lib / proxy.js View on Github external
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;
}
github scimusmn / stele / src / renderer / Settings / index.js View on Github external
value => (
                              !!((validUrl.isHttpUri(value) || validUrl.isHttpsUri(value)))
                            ),
                          )
github mongaku / mongaku / build / schemas / Record.js View on Github external
        validate: v => validUrl.isHttpsUri(v) || validUrl.isHttpUri(v),
        validationMsg: i18n => i18n.gettext("`url` must be properly-" + "formatted URL.")
github microsoft / botbuilder-tools / MSBot / bin / msbot-connect-bot.js View on Github external
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);

valid-url

URI validation functions

Unrecognized
Latest version published 11 years ago

Package Health Score

71 / 100
Full package analysis

Similar packages