mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
Merge pull request #5577 from jaswilli/issue-5574
Use correct property when determining display URL
This commit is contained in:
commit
00a644fd62
2 changed files with 104 additions and 1 deletions
|
@ -19,7 +19,7 @@ export default Ember.TextField.extend({
|
|||
|
||||
// if we have a relative url, create the absolute url to be displayed in the input
|
||||
// if (this.get('isRelative')) {
|
||||
if (!validator.isURL(url) && this.get('value').indexOf('mailto:') !== 0) {
|
||||
if (!validator.isURL(url) && url.indexOf('mailto:') !== 0) {
|
||||
url = joinUrlParts(baseUrl, url);
|
||||
}
|
||||
|
||||
|
|
103
core/client/tests/unit/components/gh-navitem-url-input-test.js
Normal file
103
core/client/tests/unit/components/gh-navitem-url-input-test.js
Normal file
|
@ -0,0 +1,103 @@
|
|||
/* jshint expr:true */
|
||||
import Ember from 'ember';
|
||||
import {expect} from 'chai';
|
||||
import {
|
||||
describeComponent,
|
||||
it
|
||||
} from 'ember-mocha';
|
||||
|
||||
describeComponent(
|
||||
'gh-navitem-url-input',
|
||||
'GhNavitemUrlInputComponent',
|
||||
{},
|
||||
function () {
|
||||
it('renders', function () {
|
||||
var component = this.subject();
|
||||
|
||||
expect(component._state).to.equal('preRender');
|
||||
|
||||
this.render();
|
||||
|
||||
expect(component._state).to.equal('inDOM');
|
||||
});
|
||||
|
||||
it('renders correctly with a URL that matches the base URL', function () {
|
||||
var component = this.subject({
|
||||
baseUrl: 'http://example.com/'
|
||||
});
|
||||
|
||||
Ember.run(function () {
|
||||
component.set('value', 'http://example.com/');
|
||||
});
|
||||
|
||||
this.render();
|
||||
|
||||
expect(this.$().val()).to.equal('http://example.com/');
|
||||
});
|
||||
|
||||
it('renders correctly with a relative URL', function () {
|
||||
var component = this.subject({
|
||||
baseUrl: 'http://example.com/'
|
||||
});
|
||||
|
||||
Ember.run(function () {
|
||||
component.set('value', '/go/docs');
|
||||
});
|
||||
|
||||
this.render();
|
||||
|
||||
expect(this.$().val()).to.equal('/go/docs');
|
||||
});
|
||||
|
||||
it('renders correctly with a mailto URL', function () {
|
||||
var component = this.subject({
|
||||
baseUrl: 'http://example.com/'
|
||||
});
|
||||
|
||||
Ember.run(function () {
|
||||
component.set('value', 'mailto:someone@example.com');
|
||||
});
|
||||
|
||||
this.render();
|
||||
|
||||
expect(this.$().val()).to.equal('mailto:someone@example.com');
|
||||
});
|
||||
|
||||
it('identifies a URL as relative', function () {
|
||||
var component = this.subject({
|
||||
baseUrl: 'http://example.com/',
|
||||
url: '/go/docs'
|
||||
});
|
||||
|
||||
this.render();
|
||||
|
||||
expect(component.get('isRelative')).to.be.ok;
|
||||
|
||||
Ember.run(function () {
|
||||
component.set('value', 'http://example.com/go/docs');
|
||||
});
|
||||
|
||||
expect(component.get('isRelative')).to.not.be.ok;
|
||||
});
|
||||
|
||||
it('identifies a URL as the base URL', function () {
|
||||
var component = this.subject({
|
||||
baseUrl: 'http://example.com/'
|
||||
});
|
||||
|
||||
this.render();
|
||||
|
||||
Ember.run(function () {
|
||||
component.set('value', 'http://example.com/');
|
||||
});
|
||||
|
||||
expect(component.get('isBaseUrl')).to.be.ok;
|
||||
|
||||
Ember.run(function () {
|
||||
component.set('value', 'http://example.com/go/');
|
||||
});
|
||||
|
||||
expect(component.get('isBaseUrl')).to.not.be.ok;
|
||||
});
|
||||
}
|
||||
);
|
Loading…
Add table
Reference in a new issue