<commit_before>package org.ambraproject.wombat.service;

import com.google.common.collect.ImmutableList;
import org.ambraproject.wombat.util.UriUtil;
import org.apache.commons.io.Charsets;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;

import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class ApiAddress {

  private final String path;
  private final ImmutableList<BasicNameValuePair> parameters;

  private ApiAddress(Builder builder) {
    this.path = builder.pathTokens.stream().collect(Collectors.joining("/"));
    this.parameters = ImmutableList.copyOf(builder.parameters);<commit_msg>DPRO-2566: Escape reserved characters in ApiAddress's path tokens<commit_after>package org.ambraproject.wombat.service;

import com.google.common.collect.ImmutableList;
import org.ambraproject.wombat.util.UriUtil;
import org.apache.commons.io.Charsets;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;

import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class ApiAddress {

  private final String path;
  private final ImmutableList<BasicNameValuePair> parameters;

  private ApiAddress(Builder builder) {
    this.path = builder.pathTokens.stream()
        .map(ApiAddress::encodePath)
        .collect(Collectors.joining("/"));
    this.parameters = ImmutableList.copyOf(builder.parameters);
  }

  private static String encodePath(String path) {
    try {
      return URLEncoder.encode(path, Charsets.UTF_8.toString());
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
{'fraction_non_alphanumeric': 0.10548302872062663, 'fraction_numerical': 0.0026109660574412533, 'mean_word_length': 5.200647249190938, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6270824', 'n_tokens_mistral': 587, 'n_tokens_neox': 583, 'n_words': 111}