Exemplo n.º 1
0
		test( 'should not change the URL if no lang is present', () => {
			assert.equal( removeLocaleFromPath( '/log-in' ), '/log-in' );
			assert.equal(
				removeLocaleFromPath( '/start/flow/step?foo=bar' ),
				'/start/flow/step?foo=bar'
			);
		} );
Exemplo n.º 2
0
		test( 'should remove the :lang part of the URL, keeping any query string', () => {
			assert.equal( removeLocaleFromPath( '/log-in/pl?foo=bar' ), '/log-in?foo=bar' );
			assert.equal(
				removeLocaleFromPath( '/start/flow/step/fr?foo=bar' ),
				'/start/flow/step?foo=bar'
			);
		} );
Exemplo n.º 3
0
		test( 'should not remove keys from an invite', () => {
			assert.equal(
				removeLocaleFromPath( '/accept-invite/site.wordpress.com/123456/es' ),
				'/accept-invite/site.wordpress.com/123456'
			);
			assert.equal(
				removeLocaleFromPath( '/accept-invite/site.wordpress.com/123456/123456/123456/es' ),
				'/accept-invite/site.wordpress.com/123456/123456/123456'
			);
		} );
Exemplo n.º 4
0
export function redirectWithoutLocaleifLoggedIn( context, next ) {
	if ( user.get() && getLocaleFromPath( context.path ) ) {
		return page.redirect( removeLocaleFromPath( context.path ) );
	}

	next();
}
Exemplo n.º 5
0
export function redirectWithoutLocaleifLoggedIn( context, next ) {
	if ( user.get() && i18nUtils.getLocaleFromPath( context.path ) ) {
		let urlWithoutLocale = i18nUtils.removeLocaleFromPath( context.path );
		return page.redirect( urlWithoutLocale );
	}

	next();
}
Exemplo n.º 6
0
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();
}
Exemplo n.º 7
0
		test( 'should not remove the :step part of the URL', () => {
			assert.equal( removeLocaleFromPath( '/start/flow/step' ), '/start/flow/step' );
		} );
Exemplo n.º 8
0
		test( 'should remove the :lang part of the URL', () => {
			assert.equal( removeLocaleFromPath( '/start/fr' ), '/start' );
			assert.equal( removeLocaleFromPath( '/start/flow/fr' ), '/start/flow' );
			assert.equal( removeLocaleFromPath( '/start/flow/step' ), '/start/flow/step' );
		} );
Exemplo n.º 9
0
		it( 'should not remove the :flow part of the URL', function() {
			assert.equal( removeLocaleFromPath( '/start' ), '/start' );
			assert.equal( removeLocaleFromPath( '/start/flow' ), '/start/flow' );
		} );
Exemplo n.º 10
0
		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 );
		}