Example #1
0
 _.forEach(result.collector.AttReadByTypeRsp, function (dataObj) {
     for (var key in dataObj.data) {
         if (_.startsWith(key, 'attrVal'))
             dataObjs.push(dataObj.data[key]);
     }
 });
 _.each(s3Assets2.results, function(asset) {
   assert.ok(_.startsWith(asset.download_url, 's3://'));
 });
Example #3
0
	return some( section.paths, path => startsWith( routeSet.path, path ) );
  .action(function(path, options) {
    if (!_.startsWith(path, '/')) {
      return utils.reject('Path must begin with /', {exit: 1});
    }

    var url = utils.addSubdomain(api.realtimeOrigin, options.instance) + path + '.json?';
    var query = {};
    if (options.shallow) { query.shallow = 'true'; }
    if (options.pretty) { query.print = 'pretty'; }
    if (options.export) { query.format = 'export'; }
    if (options.orderByKey) { options.orderBy = '$key'; }
    if (options.orderByValue) { options.orderBy = '$value'; }
    _applyStringOpts(query, options, ['limitToFirst', 'limitToLast'], ['orderBy', 'startAt', 'endAt', 'equalTo']);

    url += querystring.stringify(query);

    var reqOptions = {
      url: url
    };

    return api.addAccessTokenToHeader(reqOptions).then(function(reqOptionsWithToken) {
      return new RSVP.Promise(function(resolve, reject) {
        var fileOut = !!options.output;
        var outStream = fileOut ? fs.createWriteStream(options.output) : process.stdout;
        var erroring;
        var errorResponse = '';
        var response;

        request.get(reqOptionsWithToken)
          .on('response', function(res) {
            response = res;
            if (response.statusCode >= 400) {
              erroring = true;
            }
          })
          .on('data', function(chunk) {
            if (erroring) {
              errorResponse += chunk;
            } else {
              outStream.write(chunk);
            }
          })
          .on('end', function() {
            outStream.write('\n');
            if (erroring) {
              try {
                var data = JSON.parse(errorResponse);
                return reject(responseToError(response, data));
              } catch (e) {
                return reject(new FirebaseError('Malformed JSON response', {
                  exit: 2,
                  original: e
                }));
              }
            }
            return resolve();
          })
          .on('error', reject);
      });
    });
  });
 const scssVarList = _.filter(fs.readFileSync(src, 'utf8').split('\n'), item => _.startsWith(item, lineStartsWith));
Example #6
0
		},
		getApiBase(){
			this._throwLoadError();
			var url = coreLoader.getConfigProperty("apiRoute");

			var base = coreLoader.getConfigProperty("domain");
			
			if(coreLoader.getEnvironment() == "localhost" && coreLoader.getPlatform() == "web") {
				base = "localhost:" + coreLoader.getConfigProperty("serverLocalhostPort");
			}
			
			if(!base) {
				return url;
			}
			
			if(!_.startsWith(base, "http") && !_.startsWith(base, "https")) {
				base = "http://" + base;
			}
			

			return base + url;

		},
		isProductionMode(){
			return coreLoader.getEnvironment() === "production";
		},
		isDevelopmentMode(){
			return coreLoader.getEnvironment() === "development";
		},
		isQaMode(){
			return coreLoader.getEnvironment() === "qa";
Example #7
0
 .filter(r => _.startsWith(r.id, row.id))
Example #8
0
const defValidation = fields => fields.map(field => {

  const { val, type, required, maxLength, min, max, selections } = field
  const errors = []

  if (type === 'text') {
    if (isString(val)) {
      if (required && val === '') {
        errors.push('Field is required.')
      } else {
        if (checkStrInArr(maliciousStrings, val)) {
          errors.push('Potentially malicious input.')
        } else {
          if (val.length > maxLength) { errors.push('Input too long.') }
        }
      }
    } else {
      errors.push('Invalid data type.')
    }
  }

  if (type === 'number') {
    if (isNumber(val)) {
      if (inRange(val, min, max) === false) { errors.push('Number is out of range.') }
    }
    else { errors.push('Invalid data type.') }
  }

  if (type === 'date') {
    if (isObject(val)) {
      if (isNumber(val.year) === false || isNumber(val.month) === false || isNumber(val.day) === false) {
        errors.push('Invalid data type.')
      }
    }
    else { errors.push('Invalid data type.') }
  }

  if (type === 'selection') {
    if (isString(val)) {
      if (checkStrInArr(maliciousStrings, val)) {
        errors.push('Potentially malicious input.')
      } else {
        const selectionCodes = selections.map(option => option.camelCase)
        if (checkStrInArr(selectionCodes, val) === false) {
          errors.push('Value not in selection list.')
        }
      }
    }
    else { errors.push('Invalid data type.') }
  }

  if (type === 'mobileNumber') {
    if (isObject(val)) {
      if (isString(val.countryCode) && isString(val.phoneNumber)) {
        if (required && (val.phoneNumber === '' || val.countryCode === '')) {
          errors.push('Field is required.')
          if (startsWith(val.countryCode, '+') === false) {
            errors.push('Country code must start with a \'+\'.')
          }
        }
        if (startsWith(val.countryCode, '+') === false && required === false && val.countryCode !== '') {
          errors.push('Country code must start with a \'+\'.')
        }
      }
      else { errors.push('Invalid data type.') }
    }
    else { errors.push('Invalid data type.') }
  }

  if (type === 'boolean') {
    if (isBoolean(val) === false) { errors.push('Invalid data type.') }
  }

  return ({ ...field, errors })
})
Example #9
0
 const targetMetric = metrics.find(m => startsWith(metric.field, m.id));
 isDirectMessage (parsedMessage) {
   return _.startsWith(parsedMessage.channel, 'D', 0);
 }
internals.isPublicMessage = function (parsedMessage) {
  return _.startsWith(parsedMessage.channel, 'C', 0);
};
Example #12
0
 _.remove(routesJSON.routes, function(route) {
   return _.startsWith(_.toLower(route.handler), model);
 });
Example #13
0
 $('[href]').each(function() {
   var href = $(this).attr('href')
   if (hrefType(href) != 'relative') return
   if (startsWith(href, '/'+process.env.JUS_BASEDIR)) return
   // $(this).attr('href', path.join(process.env.JUS_BASEDIR, href).replace(/^\//, ''))
 })
Example #14
0
 $('[src]').each(function() {
   var src = $(this).attr('src')
   if (hrefType(src) != 'relative') return
   if (startsWith(src, '/'+process.env.JUS_BASEDIR)) return
   // $(this).attr('src', path.join(process.env.JUS_BASEDIR, src).replace(/^\//, ''))
 })
Example #15
0
 _.forEach(studentAttributes, function(attribute) {
   if (_.startsWith(attribute.type.code, '+')) {
     $scope.regStatus.positiveIndicators.push(attribute);
   }
 });
Example #16
0
 isUrl: function (value) {
     return _.startsWith(value, 'http')
 }
Example #17
0
 var modifier = _.find(MODIFIERS, function (it) {
     return _.startsWith(modifierWithKey, it);
 });
Example #18
0
export function setupMiddlewares( currentUser, reduxStore ) {
	debug( 'Executing WordPress.com setup middlewares.' );

	analytics.setDispatch( reduxStore.dispatch );

	if ( currentUser.get() ) {
		// When logged in the analytics module requires user and superProps objects
		// Inject these here
		analytics.initialize( currentUser, superProps );
	} else {
		analytics.setSuperProps( superProps );
	}

	// Render Layout only for non-isomorphic sections.
	// Isomorphic sections will take care of rendering their Layout last themselves.
	if ( ! document.getElementById( 'primary' ) ) {
		renderLayout( reduxStore );

		if ( config.isEnabled( 'catch-js-errors' ) ) {
			const errorLogger = new Logger();
			//Save errorLogger to a singleton for use in arbitrary logging.
			require( 'lib/catch-js-errors/log' ).registerLogger( errorLogger );
			//Save data to JS error logger
			errorLogger.saveDiagnosticData( {
				user_id: currentUser.get().ID,
				calypso_env: config( 'env_id' ),
			} );
			errorLogger.saveDiagnosticReducer( function() {
				const state = reduxStore.getState();
				return {
					blog_id: getSelectedSiteId( state ),
					calypso_section: getSectionName( state ),
				};
			} );
			errorLogger.saveDiagnosticReducer( () => ( { tests: getSavedVariations() } ) );
			analytics.on( 'record-event', ( eventName, eventProperties ) =>
				errorLogger.saveExtraData( { lastTracksEvent: eventProperties } )
			);
			page( '*', function( context, next ) {
				errorLogger.saveNewPath(
					context.canonicalPath.replace( getSiteFragment( context.canonicalPath ), ':siteId' )
				);
				next();
			} );
		}
	}

	// If `?sb` or `?sp` are present on the path set the focus of layout
	// This can be removed when the legacy version is retired.
	page( '*', function( context, next ) {
		if ( [ 'sb', 'sp' ].indexOf( context.querystring ) !== -1 ) {
			const layoutSection = context.querystring === 'sb' ? 'sidebar' : 'sites';
			reduxStore.dispatch( setNextLayoutFocus( layoutSection ) );
			page.replace( context.pathname );
		}

		next();
	} );

	page( '*', function( context, next ) {
		// Don't normalize legacy routes - let them fall through and be unhandled
		// so that page redirects away from Calypso
		if ( isLegacyRoute( context.pathname ) ) {
			return next();
		}

		return normalize( context, next );
	} );

	page( '*', function( context, next ) {
		const path = context.pathname;

		// Bypass this global handler for legacy routes
		// to avoid bumping stats and changing focus to the content
		if ( isLegacyRoute( path ) ) {
			return next();
		}

		// Focus UI on the content on page navigation
		if ( ! config.isEnabled( 'code-splitting' ) ) {
			context.store.dispatch( activateNextLayoutFocus() );
		}

		// Bump general stat tracking overall Newdash usage
		analytics.mc.bumpStat( { newdash_pageviews: 'route' } );

		next();
	} );

	page( '*', function( context, next ) {
		if ( '/me/account' !== context.path && currentUser.get().phone_account ) {
			page( '/me/account' );
		}

		next();
	} );

	page( '*', emailVerification );

	// delete any lingering local storage data from signup
	if ( ! startsWith( window.location.pathname, '/start' ) ) {
		[ 'signupProgress', 'signupDependencies' ].forEach( store.remove );
	}

	if ( ! currentUser.get() ) {
		// Dead-end the sections the user can't access when logged out
		page( '*', function( context, next ) {
			//see server/pages/index for prod redirect
			if ( '/plans' === context.pathname ) {
				const queryFor = context.query && context.query.for;
				if ( queryFor && 'jetpack' === queryFor ) {
					window.location =
						'https://wordpress.com/wp-login.php?redirect_to=https%3A%2F%2Fwordpress.com%2Fplans';
				} else {
					// pricing page is outside of Calypso, needs a full page load
					window.location = 'https://wordpress.com/pricing';
				}
				return;
			}

			next();
		} );
	}

	setupMySitesRoute();

	const state = reduxStore.getState();
	if ( config.isEnabled( 'happychat' ) ) {
		reduxStore.dispatch( requestHappychatEligibility() );
	}
	if ( wasHappychatRecentlyActive( state ) ) {
		reduxStore.dispatch( initHappychatConnection( getHappychatAuth( state )() ) );
	}

	if ( config.isEnabled( 'keyboard-shortcuts' ) ) {
		setupGlobalKeyboardShortcuts();
	}

	if ( config.isEnabled( 'desktop' ) ) {
		require( 'lib/desktop' ).default.init();
	}

	if ( config.isEnabled( 'rubberband-scroll-disable' ) ) {
		asyncRequire( 'lib/rubberband-scroll-disable', disableRubberbandScroll => {
			disableRubberbandScroll( document.body );
		} );
	}

	if (
		config.isEnabled( 'dev/test-helper' ) &&
		document.querySelector( '.environment.is-tests' )
	) {
		asyncRequire( 'lib/abtest/test-helper', testHelper => {
			testHelper( document.querySelector( '.environment.is-tests' ) );
		} );
	}
	if (
		config.isEnabled( 'dev/preferences-helper' ) &&
		document.querySelector( '.environment.is-prefs' )
	) {
		asyncRequire( 'lib/preferences-helper', prefHelper => {
			prefHelper( document.querySelector( '.environment.is-prefs' ), reduxStore );
		} );
	}
}
Example #19
0
 const seriesData = series.filter(r => _.startsWith(r.id, s.id));
Example #20
0
 const match = find(array, el => startsWith(str, el));
Example #21
0
 .filter(r => _.startsWith(r.id, s.id))
Example #22
0
PullRequest.prototype.getPullRequestNumberFromBranch_ = function(currentBranch, prefix) {
    if (currentBranch && _.startsWith(currentBranch, prefix)) {
        return currentBranch.replace(prefix, '')
    }
}
Example #23
0
export function replacer(key, value) {
  return isString(key) && startsWith(key, '$') ? undefined : value;
}
 stack, s => _.startsWith(s, this.nav.HOME_PAGE)),
 varsAndValues = _.filter(varsAndValues, ({ value }) => !_.startsWith(value, '$'));
Example #26
0
 call.on('metadata', function(metadata) {
   assert(_.startsWith(metadata.get('user-agent')[0],
                       'grpc-node/' + version));
   done();
 });
Example #27
0
	const config = find( FIRST_VIEW_CONFIG, ( entry => some( entry.paths, entryPath => startsWith( path, entryPath ) ) ) );
 list = functionList.filter(func => _.startsWith(func.name, message.function));
Example #29
0
 _.forOwn(this, function(value, key) {
   if (!_.startsWith(key, '_') && ! _.isFunction(value)) {
     clone[key] = value;
   }
 });
		const candidate = find( post.attachments, ( { mime_type } ) => startsWith( mime_type, 'image/' ) );