sub extract_path_segment {
  if (std.strlen(beresp.http.tmp-path) > 0) {
    set beresp.http.surrogate-key = if (beresp.http.surrogate-key, beresp.http.surrogate-key " " beresp.http.tmp-path, beresp.http.tmp-path);
    set beresp.http.tmp-path = regsub(beresp.http.tmp-path, "^(.*?)/[^/]*$", "\1");
  }
}