Skip to content

Commit

Permalink
Merge a2827fc into 723a15d
Browse files Browse the repository at this point in the history
  • Loading branch information
gkchestertron committed Mar 29, 2018
2 parents 723a15d + a2827fc commit 7402021
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion addon/services/frost-page-title.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ export default Service.extend({
.filter(section => !/[^A-Za-z-]/.test(section))
.map(section => {
return section.split('-')
.map(word => EmberString.capitalize(word))
.map((word, idx) => {
if (idx === 0) {
return EmberString.capitalize(word)
}
return word
})
.join(' ')
})
},
Expand All @@ -69,6 +74,7 @@ export default Service.extend({
const sections = handlers.reduce((acc, handler) => {
return handler(acc, defaultTitle)
}, this.defaultHandler(url))
.filter(section => !!section)

if (sections.length) {
document.title = sections.join(` ${delimiter} `)
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/application-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ describe('Acceptance: Application', function () {
;[
['custom-title', 'Hello | Custom | Title'],
['custom-title/nested', 'Hello | Custom | (Nested) Title'],
['default-title', 'Default Title'],
['default-title/nested', 'Default Title | Nested']
['default-title', 'Default title'],
['default-title/nested', 'Default title | Nested']
]
.forEach(([path, title]) => {
describe(`visit /${path}`, function () {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/services/frost-page-title-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe(test.label, function () {
describe('defaultHandler', function () {
it('should return capitalized version of words from window.location.hash', function () {
window.location.hash = '/foo-bar'
expect(service.defaultHandler()).to.eql(['Foo Bar'])
expect(service.defaultHandler()).to.eql(['Foo bar'])
})

it('should ignore non-wordy things', function () {
Expand Down

0 comments on commit 7402021

Please sign in to comment.