Skip to content

Commit 31e0101

Browse files
authored
fix(live-example): correctly match example name (angular#2815)
Currently, when visiting a page with a relative link e.g. https://angular.io/docs/ts/latest/guide/testing.html#!#top, `NgIoUtil.getExampleName` fails to match the example name. This results on `live-example` directives on that page missing the example name in the link: instead of linking to https://angular.io/resources/live-examples/testing/ts/plnkr.html it will link to https://angular.io/resources/live-examples//ts/plnkr.html (notice the missing `testing` and the double slashes).
1 parent e0aecb3 commit 31e0101

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

public/resources/js/util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ var NgIoUtil = (function () {
7777
// TODO: use $location.path() instead(?). It seems to be empty.
7878
var loc = $location.absUrl();
7979
// E.g., https://example.com/docs/dart/latest/guide/displaying-data.html
80-
var matches = loc.match(/.*\/([\w\-]+)(\.html)?$/);
80+
var matches = loc.match(/.*\/([\w\-]+)(\.html)?/);
8181
if (matches) NgIoUtil.setExampleName(matches[1]); // cache name
8282
}
8383
return NgIoUtil._exampleName;

0 commit comments

Comments
 (0)