Index: client/web/app.dart |
diff --git a/client/web/app.dart b/client/web/app.dart |
index 9f2c9964752fc666a2a0953bfa6e589b0dd94aa0..935e5c01941d47db85094554668f14298651a701 100644 |
--- a/client/web/app.dart |
+++ b/client/web/app.dart |
@@ -250,7 +250,7 @@ class Viewer extends Observable { |
String _replaceLocation(DocsLocation location) { |
var newUri = location.withAnchor; |
var encoded = Uri.encodeFull(newUri); |
- window.location.replace("#$encoded"); |
+ window.location.replace(locationPrefixed(encoded)); |
return encoded; |
} |
@@ -345,11 +345,11 @@ class Viewer extends Observable { |
// Links are the hash part of the URI without the leading #. |
// Valid forms for links are |
// home - the global home page |
- // library.memberName.subMember#anchor |
- // where #anchor is optional and library can be any of |
+ // library.memberName.subMember@anchor |
+ // where @anchor is optional and library can be any of |
// dart:library, library-foo, package-foo/library-bar |
// So we need an unambiguous form. |
- // [package/]libraryWithDashes[.class.method]#anchor |
+ // [package/]libraryWithDashes[.class.method]@anchor |
// We will tolerate colons in the location instead of dashes, though |
var decoded = Uri.decodeFull(uri); |
@@ -417,15 +417,29 @@ String _pathname; |
/// The latest url reached by a popState event. |
String location; |
+/// The google crawler will try to translate #! anchors into query parameters |
+/// with an _escaped_fragment_ in front of them. Assume that's the only query |
+/// parameter. |
+const _ESCAPED_FRAGMENT = '?_escaped_fragment_='; |
+String findLocation() { |
Emily Fortuna
2014/02/04 01:47:51
add a comment to this function and add a newline
Alan Knight
2014/02/04 18:08:14
Done.
|
+ var hash = window.location.hash; |
+ var query = window.location.search; |
+ if (query.startsWith(_ESCAPED_FRAGMENT)) { |
+ return query.substring(_ESCAPED_FRAGMENT.length, query.length); |
+ } else { |
+ return locationDeprefixed(hash); |
+ } |
+} |
+ |
/// Listens for browser navigation and acts accordingly. |
void startHistory() { |
- location = window.location.hash.replaceFirst('#', ''); |
+ location = findLocation(); |
windowLocation.changes.listen(navigate); |
} |
void navigate(event) { |
// TODO(alanknight): Should we be URI encoding/decoding this? |
- var newLocation = window.location.hash.replaceFirst('#', ''); |
+ var newLocation = findLocation(); |
if (viewer.homePage != null) { |
viewer.handleLink(newLocation); |
} |