manuel-schoebel / ms-seo

A seo helper package for meteor.js
198 stars 55 forks source link

Exception when setting title for dataNotFound route #56

Open kucharzyk opened 9 years ago

kucharzyk commented 9 years ago

When visiting not-existent page while using dataNotFound plugin We get exception like this:

Exception from Tracker recompute function: debug.js:41 TypeError: Cannot read property 'getName' of undefined

Problem is in following method:

getCurrentRouteName = ->
  router = Router.current()
  return unless router
  routeName = router.route.getName()
  return routeName

We check is ruter is undefined but in this case routes is defined but router.route is not.

It would be nice to add additional check for router.route or maybe special SeoCollection item for undefined 'dataNotFound' route.

kucharzyk commented 9 years ago

Temporary solution for this exception may be additional 'catch-all' route but It do not work well with useraccounts package

Router.route("/(.*)", {
    name: "notFound"
});
for2ne commented 9 years ago

This is a bug. All "notFount" pages:

TypeError: Cannot read property 'getName' of undefined

because:

getCurrentRouteName = function() {
  var routeName, router;
  router = Router.current();
  if (!router) {
    return;
  }
  routeName = router.route.getName(); // router.route === "undefined" for all "NotFound" pages
  return routeName;
};

Pull request #58