Chromium Code Reviews| Index: pdf/instance.cc |
| diff --git a/pdf/instance.cc b/pdf/instance.cc |
| index 9b4d52ac684e11a722f01efbde712b88a93068d2..893399278ee8c4c4b7e994e435062b78ae6a2e01 100644 |
| --- a/pdf/instance.cc |
| +++ b/pdf/instance.cc |
| @@ -1226,7 +1226,13 @@ void Instance::NavigateTo(const std::string& url, bool open_in_new_tab) { |
| // If |url_copy| starts with '#', then it's for the same URL with a |
| // different URL fragment. |
| if (url_copy[0] == '#') { |
| - url_copy = url_ + url_copy; |
| + // if '#' is already present in |url_| then remove old tag and add new |
|
Lei Zhang
2015/01/08 04:55:54
The proper name for 'tag' is fragment BTW. http://
|
| + // |url_copy| tag. |
| + std::size_t index = url_.find('#'); |
| + if (index != std::string::npos) |
| + url_copy = url_.substr(0, index) + url_copy; |
| + else |
| + url_copy = url_ + url_copy; |
| // Changing the href does not actually do anything when navigating in the |
| // same tab, so do the actual page scroll here. Then fall through so the |
| // href gets updated. |