コード例 #1
0
ファイル: utils.js プロジェクト: princetoad/wp-calypso
		test( 'should return locale string when at end of path', () => {
			assert.equal( getLocaleFromPath( '/start/es' ), 'es' );
			assert.equal(
				getLocaleFromPath( '/accept-invite/site.wordpress.com/123456/123456/123456/es' ),
				'es'
			);
		} );
コード例 #2
0
ファイル: controller.js プロジェクト: liquizzz/wp-calypso
export function redirectWithoutLocaleifLoggedIn( context, next ) {
	if ( user.get() && getLocaleFromPath( context.path ) ) {
		return page.redirect( removeLocaleFromPath( context.path ) );
	}

	next();
}
コード例 #3
0
export function redirectWithoutLocaleifLoggedIn( context, next ) {
	if ( user.get() && i18nUtils.getLocaleFromPath( context.path ) ) {
		let urlWithoutLocale = i18nUtils.removeLocaleFromPath( context.path );
		return page.redirect( urlWithoutLocale );
	}

	next();
}
コード例 #4
0
ファイル: controller.js プロジェクト: liquizzz/wp-calypso
export function redirectWithoutLocaleIfLoggedIn( context, next ) {
	const isLoggedIn = !! getCurrentUserId( context.store.getState() );
	if ( isLoggedIn && getLocaleFromPath( context.path ) ) {
		const urlWithoutLocale = removeLocaleFromPath( context.path );
		debug( 'redirectWithoutLocaleIfLoggedIn to %s', urlWithoutLocale );
		return page.redirect( urlWithoutLocale );
	}

	next();
}
コード例 #5
0
ファイル: utils.js プロジェクト: princetoad/wp-calypso
		test( 'should correctly handle paths with query string', () => {
			assert.equal( getLocaleFromPath( '/start/es?query=string' ), 'es' );
		} );
コード例 #6
0
ファイル: utils.js プロジェクト: princetoad/wp-calypso
		test( 'should return undefined when no locale at end of path', () => {
			assert.equal( getLocaleFromPath( '/start' ), undefined );
		} );
コード例 #7
0
ファイル: controller.js プロジェクト: blowery/wp-calypso
	renderWithReduxStore(
		React.createElement( JetpackConnect, {
			path: context.path,
			context: context,
			type: type,
			userModule: userModule,
			locale: context.params.locale
		} ),
		document.getElementById( 'primary' ),
		context.store
	);
};

export default {
	redirectWithoutLocaleifLoggedIn( context, next ) {
		if ( userModule.get() && i18nUtils.getLocaleFromPath( context.path ) ) {
			const urlWithoutLocale = i18nUtils.removeLocaleFromPath( context.path );
			return page.redirect( urlWithoutLocale );
		}

		next();
	},

	saveQueryObject( context, next ) {
		if ( ! isEmpty( context.query ) && context.query.redirect_uri ) {
			debug( 'set initial query object', context.query );
			context.store.dispatch( {
				type: JETPACK_CONNECT_QUERY_SET,
				queryObject: context.query
			} );
			page.redirect( context.pathname );