<commit_before>import {Router, history} from 'backbone';
import Search from 'yourturn/src/search/search';
import puppeteer from 'common/src/puppeteer';
import {Provider} from 'common/src/oauth-provider';
import {Error} from 'oauth2-client-js';
import Flux from './flux';

const NOTIFICATIONS = Flux.getActions('notification');
const MAIN_VIEW_ID = '#yourturn-view';

class YourturnRouter extends Router {
    constructor() {
        super({
            routes: {
                '': 'search',
                'search': 'search',
                'oauth': 'oauth'
            }
        });
    }

    search() {
        puppeteer.show(new Search(), MAIN_VIEW_ID);
    }

    oauth() {
        let response;
        try {
            response = Provider.parse(window.location.hash);
        } catch(err) {
            NOTIFICATIONS.addNotification('OAuth: Unexpected response. This should not happen.', 'error');
            return history.navigate(response.metadata.route || '/', { trigger: true });
        }
        if (response) {
            if (response instanceof Error) {
                return NOTIFICATIONS.addNotification('OAuth: ' + response.error + ' ' + response.getMessage(), 'error');
            }
            history.navigate(response.metadata.route || '/', { trigger: true });
        }
    }
}

export default YourturnRouter;<commit_msg>#54 do not use non-existing response<commit_after>import {Router, history} from 'backbone';
import Search from 'yourturn/src/search/search';
import puppeteer from 'common/src/puppeteer';
import {Provider} from 'common/src/oauth-provider';
import {Error} from 'oauth2-client-js';
import Flux from './flux';

const NOTIFICATIONS = Flux.getActions('notification');
const MAIN_VIEW_ID = '#yourturn-view';

class YourturnRouter extends Router {
    constructor() {
        super({
            routes: {
                '': 'search',
                'search': 'search',
                'oauth': 'oauth'
            }
        });
    }

    search() {
        puppeteer.show(new Search(), MAIN_VIEW_ID);
    }

    oauth() {
        let response;
        try {
            response = Provider.parse(window.location.hash);
        } catch(err) {
            NOTIFICATIONS.addNotification('OAuth: Unexpected response. This should not happen.', 'error');
            return history.navigate('/', { trigger: true });
        }
        if (response) {
            if (response instanceof Error) {
                return NOTIFICATIONS.addNotification('OAuth: ' + response.error + ' ' + response.getMessage(), 'error');
            }
            history.navigate(response.metadata.route || '/', { trigger: true });
        }
    }
}

export default YourturnRouter;
{'fraction_non_alphanumeric': 0.1346153846153846, 'fraction_numerical': 0.0014792899408284023, 'mean_word_length': 2.270858524788392, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6180470', 'n_tokens_mistral': 767, 'n_tokens_neox': 762, 'n_words': 170}