anchor.diff:              canonicalize_qs(T)
       end.
   
  +%% XXX TODO:  this is conditional to make unit tests pass.
  +%%            the webmachine resources need to support
  +%%            vhost-style bucket addressing so that things
  +%%            like path_info([key|bucket]) work properly.
  +%%
  +%%            the test version of canonicalize_resource
  +%%            doesn't use path_info, allowing the unit
  +%%            tests to pass.
  +-ifdef(TEST).
   bucket_from_host(undefined, RD) ->
       wrq:path_info(bucket, RD);
   bucket_from_host(HostHeader, RD) ->
  
positive.code:     end.
  -else.
  canonicalize_resource(RD) ->
      case {bucket_from_host(wrq:get_req_header("host", RD), RD),
            wrq:path_tokens(RD)} of
          {undefined, []} -> ["/"];
          {undefined, _} -> [wrq:path(RD)];
          {Bucket, []} ->
              %% SLF: imho, this sucks.  If we tell WM to route via
              %%      ["riak-cs", '*'], then we don't end up at this
              %%      clause.  But if we use ["riak-cs", "stats"], then
              %%      wrq:path_tokens(RD) will return [], and we end up
              %%      in this clause, and then we do The Wrong Thing(tm).
              SlashBucket = "/" ++ Bucket,
              WrqPath = wrq:path(RD),
              case string:str(WrqPath, SlashBucket) of
                  1 ->
                      Rest = string:substr(WrqPath, length(SlashBucket) + 1),
                     ["/", Bucket, Rest];
                  _ ->
                      ["/", Bucket, "/"]
              end;
          {Bucket, KeyTokens} ->
              ["/", Bucket, "/", string:join(KeyTokens, "/")]
      end.
  -endif.
  
  %% ===================================================================
  
negative.code:             end
      end.
  
  canonicalize_resource(RD) ->
      case bucket_from_host(wrq:get_req_header("host", RD), RD) of
          undefined ->
  