<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package com.androidzeitgeist.webcards.processing.pre;

import android.net.Uri;

import okhttp3.Request;

/**
 * Google+ uses a JavaScript based redirector. This pre processor will extract the actual URL from
 * the redirector URL and create a new request.
 */
public class GooglePlusPreProcessor implements PreProcessor {
    private static final String URL_PREFIX = "https://plus.url.google.com/url?q=";

    @Override
    public Request process(Request request) {
        final String url = request.url().toString();

        if (url.startsWith(URL_PREFIX)) {
            final String actualUrl = Uri.parse(url).getQueryParameter("q");

            return request.newBuilder()
                    .url(actualUrl)
                    .build();
        }

        return request;
    }
}
<commit_msg>Make Google+ pre processor less strict.<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package com.androidzeitgeist.webcards.processing.pre;

import android.net.Uri;

import okhttp3.Request;

/**
 * Google+ uses a JavaScript based redirector. This pre processor will extract the actual URL from
 * the redirector URL and create a new request.
 */
public class GooglePlusPreProcessor implements PreProcessor {
    private static final String URL_PREFIX = "://plus.url.google.com/url?q=";

    @Override
    public Request process(Request request) {
        final String url = request.url().toString();

        if (url.contains(URL_PREFIX)) {
            final String actualUrl = Uri.parse(url).getQueryParameter("q");

            if (actualUrl != null) {
                return request.newBuilder()
                        .url(actualUrl)
                        .build();
            }
        }

        return request;
    }
}

{'fraction_non_alphanumeric': 0.09698681732580038, 'fraction_numerical': 0.004708097928436911, 'mean_word_length': 2.5475792988313857, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '2020444', 'n_tokens_mistral': 579, 'n_tokens_neox': 556, 'n_words': 200}