Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Add host to title mode
Browse files Browse the repository at this point in the history
Auditors: @diracdeltas
  • Loading branch information
bbondy committed Feb 8, 2016
1 parent c28e6ea commit a6776d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion js/components/urlBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,16 @@ class UrlBar extends ImmutableComponent {
}

get titleValue () {
const parsedUrl = urlParse(this.props.activeFrameProps.get('location'))
let titlePrefix = ''
if (parsedUrl.protocol !== 'about:') {
titlePrefix += parsedUrl.host + ' | '

This comment has been minimized.

Copy link
@diracdeltas

diracdeltas Feb 8, 2016

Member

should probably check if host is null/empty

}

// For about:newtab we don't want the top of the browser saying New Tab
// Instead just show "Brave"
return ['about:blank', 'about:newtab'].includes(this.props.urlbar.get('location'))
? '' : this.props.activeFrameProps.get('title')
? '' : titlePrefix + this.props.activeFrameProps.get('title')
}

get locationValue () {
Expand Down
5 changes: 4 additions & 1 deletion test/navigationBarTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const Brave = require('./lib/brave')
const Config = require('../js/constants/config').default
const {urlInput, activeWebview, activeTabFavicon, activeTab, navigatorLoadTime, urlbarIcon} = require('./lib/selectors')
const urlParse = require('url').parse
const assert = require('assert')

describe('urlbar', function () {
Expand Down Expand Up @@ -58,14 +59,16 @@ describe('urlbar', function () {

before(function *() {
this.page1Url = Brave.server.url('page1.html')
this.host = urlParse(this.page1Url).host
yield setup(this.app.client)
yield navigate(this.app.client, this.page1Url)
yield this.app.client.waitForValue(urlInput)
})

it('has title mode', function *() {
const host = this.host
yield this.app.client.waitUntil(function () {
return this.getValue(urlInput).then(val => val === 'Page 1')
return this.getValue(urlInput).then(val => val === host + ' | Page 1')

This comment has been minimized.

Copy link
@diracdeltas

diracdeltas Feb 8, 2016

Member

i made the host bold to distinguish from pages that have '|' in the title

This comment has been minimized.

Copy link
@diracdeltas

diracdeltas Feb 8, 2016

Member

sorry, this was supposed to be a comment in urlBar.js, not here

})
.isExisting(navigatorLoadTime).then(isExisting => assert(!isExisting))
})
Expand Down

1 comment on commit a6776d0

@diracdeltas
Copy link
Member

Choose a reason for hiding this comment

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

i made these fixes already in my version of this commit, so no need for you to fix. i'll push it now.

Please sign in to comment.