ms-seo
ms-seo copied to clipboard
fix Router.current().route for NotFound route
#56 and etc.
Fix bug "TypeError: Cannot read property 'getName' of undefined" for "NotFound" route
@DerMambo please merge at your earliest convenience :)
@for2ne please consider @lhristov comment in order to merge this. Thanks!
@lhristov no. Error is disappear with OR only. was tested :) @fentas no problems
http://js2.coffee/ gives me:
return unless router or router.route
becomes
if (!(router || router.route)) {
return;
}
@for2ne Strange. This meens if router is undefined/false it checks router.route (which is then undefined.route >> error should be thrown).
With and (if (!(router && router.route))) router.route will be checked if route is not undefined/false.
I would say and should be the right one.
Or do I miss something?
Hm. If return unless router or router.route would become if (!router || !router.route) then it would be right.
@fentas you are absolutely right, my bad. I am not good in cofeescript. Error disappeared, but the function probably will return a wrong result...
for good, function getCurrentRouteName should look like this:
getCurrentRouteName = function() {
var router = Router.current();
if (router && router.route) {
return router.route.getName();
}
return;
};
@for2ne right.
getCurrentRouteName = ->
router = Router.current()
return router.route.getName() if router and router.route
becomes
getCurrentRouteName = function() {
var router;
router = Router.current();
if (router && router.route) {
return router.route.getName();
}
};
This should be sufficient. It does not matter if you do a return in the end. With or without both becomes undefined as return value.
The author should give write access to someone...