Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

SUP-2793, missing url protocol issue with external web link cards #598

Merged
merged 1 commit into from
Dec 8, 2015
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@
p.link-title(data-ellipsis, ng-bind="account.title", ng-hide="account.status === 'PENDING'")
p.link-title(ng-show="account.status === 'PENDING'") Loading data. This will take a few minutes.

a.link-url(ng-href="{{account.URL}}", ng-bind="account.URL")
a.link-url(ng-href="{{account.URL | urlProtocol}}", ng-bind="account.URL")
17 changes: 16 additions & 1 deletion app/filters/filters.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ describe('filters', function() {

beforeEach(function() {
bard.appModule('topcoder');
bard.inject(this, 'CONSTANTS', 'roleFilter', 'percentageFilter', 'ordinalFilter', 'displayLocationFilter', 'listRolesFilter', 'trackFilter', 'challengeLinksFilter', 'externalLinkColorFilter', 'emptyFilter', 'ternaryFilter');
bard.inject(this, 'CONSTANTS', 'roleFilter', 'percentageFilter', 'ordinalFilter', 'displayLocationFilter', 'listRolesFilter', 'trackFilter', 'challengeLinksFilter', 'externalLinkColorFilter', 'emptyFilter', 'ternaryFilter', 'urlProtocolFilter');
domain = CONSTANTS.domain;
});

Expand Down Expand Up @@ -135,4 +135,19 @@ describe('filters', function() {
expect(ternaryFilter(true, 'm', 'n')).to.be.equal('m');
});
});

describe('urlProtocolFilter', function() {
it('should add http to the url ', function() {
expect(urlProtocolFilter('google.com')).to.be.equal('http://google.com');
});
it('should add http to the url ', function() {
expect(urlProtocolFilter('www.google.com')).to.be.equal('http://www.google.com');
});
it('should not add anything to the url ', function() {
expect(urlProtocolFilter('http://google.com')).to.be.equal('http://google.com');
});
it('should not add anything to the url ', function() {
expect(urlProtocolFilter('https://google.com')).to.be.equal('https://google.com');
});
});
});
23 changes: 23 additions & 0 deletions app/filters/url-protocol.filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(function() {
'use strict';

angular.module('topcoder').filter('urlProtocol', urlProtocol);

function urlProtocol() {
return function(link) {
if (!link) {
return link;
}
var result;
var startingUrl = "http://";
var httpsStartingUrl = "https://";
if(link.indexOf(startingUrl) === 0||link.indexOf(httpsStartingUrl) === 0) {
result = link;
} else {
result = startingUrl + link;
}
return result;
};
}

})();
1 change: 1 addition & 0 deletions app/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ html
script(src="filters/track.filter.js")
script(src="filters/truncate.filter.js")
script(src="filters/underscore-strip.filter.js")
script(src="filters/url-protocol.filter.js")
script(src="layout/layout.module.js")
script(src="layout/header/header.controller.js")
script(src="my-challenges/my-challenges.module.js")
Expand Down