<commit_before>package com.github.dreamhead.moco.handler.proxy;

import static com.github.dreamhead.moco.util.URLs.join;
import static com.github.dreamhead.moco.util.URLs.toBase;
import static com.google.common.base.Strings.nullToEmpty;

public class ProxyConfig {
    private final String localBase;
    private final String remoteBase;

    public ProxyConfig(String localBase, String remoteBase) {
        this.localBase = localBase;
        this.remoteBase = remoteBase;
    }

    public String localBase() {
        return this.localBase;
    }

    public String remoteBase() {
        return this.remoteBase;
    }

    public boolean canAccessedBy(String uri) {
        return uri.startsWith(localBase);
    }

    public String remoteUrl(String uri) {
        String relative = nullToEmpty(uri.replaceFirst(this.localBase, ""));
        return join(remoteBase, relative);
    }

    public static Builder builder(String localBase) {
        return new Builder(localBase);
    }

    public static class Builder {
        private final String localBase;

        public Builder(String localBase) {
            this.localBase = localBase;
        }

        public ProxyConfig to(final String remoteBase) {
            return new ProxyConfig(toBase(localBase), toBase(remoteBase));
        }
    }
}<commit_msg>checked remote base as not null or empty<commit_after>package com.github.dreamhead.moco.handler.proxy;

import static com.github.dreamhead.moco.Moco.checkNotNullOrEmpty;
import static com.github.dreamhead.moco.util.URLs.join;
import static com.github.dreamhead.moco.util.URLs.toBase;
import static com.google.common.base.Strings.nullToEmpty;

public class ProxyConfig {
    private final String localBase;
    private final String remoteBase;

    public ProxyConfig(String localBase, String remoteBase) {
        this.localBase = localBase;
        this.remoteBase = remoteBase;
    }

    public String localBase() {
        return this.localBase;
    }

    public String remoteBase() {
        return this.remoteBase;
    }

    public boolean canAccessedBy(String uri) {
        return uri.startsWith(localBase);
    }

    public String remoteUrl(String uri) {
        String relative = nullToEmpty(uri.replaceFirst(this.localBase, ""));
        return join(remoteBase, relative);
    }

    public static Builder builder(String localBase) {
        return new Builder(localBase);
    }

    public static class Builder {
        private final String localBase;

        public Builder(String localBase) {
            this.localBase = localBase;
        }

        public ProxyConfig to(final String remoteBase) {
            return new ProxyConfig(toBase(localBase), toBase(checkNotNullOrEmpty(remoteBase, "Remote base should not be null")));
        }
    }
}
{'fraction_non_alphanumeric': 0.08435032304379038, 'fraction_numerical': 0.0, 'mean_word_length': 2.925352112676056, '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': '6443319', 'n_tokens_mistral': 785, 'n_tokens_neox': 761, 'n_words': 190}