Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #142 #143

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/services/page-title-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function capitalize(key) {

let defaults = {};
['separator', 'prepend', 'replace'].forEach(function (key) {
if (config.pageTitle && config.pageTitle[key]) {
if (config.pageTitle && (config.pageTitle[key] !== null) && (config.pageTitle[key] !== undefined)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: Adding safety checks is a great idea. I wonder if we can make this logic clearer using a more functional programming style:

let defaults = {};
let {pageTitle = {}} = config;
['separator', 'prepend', 'replace']
  .filter(key => {
    return key in pageTitle && pageTitle[key];
  })
  .forEach(function (key) {
    defaults[`default${capitalize(key)}`] = pageTitle[key];
  });

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if a functional programming style makes it clearer, actually. How about if we go to ember utils, and use isPresent, instead?

Do you think

if(config.pageTitle && isPresent(config.pageTitle[key]))...

is clearer?

defaults[`default${capitalize(key)}`] = config.pageTitle[key];
}
});
Expand Down