Commit 55567738 authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

[Import Maps] Fix ImportMap::ToString() to return a valid JSON string

As a preparation for adding parser-related tests.

Bug: 990561
Change-Id: Iebd54fe15ae2943ea9f5cc9aeefac4d32a854316
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1734195
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685517}
parent 07a8c371
......@@ -446,19 +446,27 @@ base::Optional<KURL> ImportMap::ResolveImportsMatchInternal(
String ImportMap::ToString() const {
StringBuilder builder;
builder.Append("{\n");
builder.Append("{");
bool is_first_key = true;
for (const auto& it : imports_) {
builder.Append(" \"");
if (!is_first_key)
builder.Append(",");
is_first_key = false;
builder.Append("\n \"");
builder.Append(it.key);
builder.Append("\": [\n");
builder.Append("\": [");
bool is_first_value = true;
for (const auto& v : it.value) {
builder.Append(" \"");
if (!is_first_value)
builder.Append(",");
is_first_value = false;
builder.Append("\n \"");
builder.Append(v.GetString());
builder.Append("\",\n");
builder.Append("\"");
}
builder.Append(" ]\n");
builder.Append("\n ]");
}
builder.Append("}\n");
builder.Append("\n}\n");
return builder.ToString();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment