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

Commit f35b651

Browse files
author
Nick Litwin
committed
2 parents c5b38e0 + 8dff1ed commit f35b651

File tree

5 files changed

+42
-3
lines changed

5 files changed

+42
-3
lines changed

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.0.16
1+
v1.0.17

app/directives/external-account/external-link-data.directive.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,4 @@
102102
p.link-title(data-ellipsis, ng-bind="account.title", ng-hide="account.status === 'PENDING'")
103103
p.link-title(ng-show="account.status === 'PENDING'") Loading data. This will take a few minutes.
104104

105-
a.link-url(ng-href="{{account.URL}}", ng-bind="account.URL")
105+
a.link-url(ng-href="{{account.URL | urlProtocol}}", ng-bind="account.URL")

app/filters/filters.spec.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ describe('filters', function() {
33

44
beforeEach(function() {
55
bard.appModule('topcoder');
6-
bard.inject(this, 'CONSTANTS', 'roleFilter', 'percentageFilter', 'ordinalFilter', 'displayLocationFilter', 'listRolesFilter', 'trackFilter', 'challengeLinksFilter', 'externalLinkColorFilter', 'emptyFilter', 'ternaryFilter');
6+
bard.inject(this, 'CONSTANTS', 'roleFilter', 'percentageFilter', 'ordinalFilter', 'displayLocationFilter', 'listRolesFilter', 'trackFilter', 'challengeLinksFilter', 'externalLinkColorFilter', 'emptyFilter', 'ternaryFilter', 'urlProtocolFilter');
77
domain = CONSTANTS.domain;
88
});
99

@@ -135,4 +135,19 @@ describe('filters', function() {
135135
expect(ternaryFilter(true, 'm', 'n')).to.be.equal('m');
136136
});
137137
});
138+
139+
describe('urlProtocolFilter', function() {
140+
it('should add http to the url ', function() {
141+
expect(urlProtocolFilter('google.com')).to.be.equal('http://google.com');
142+
});
143+
it('should add http to the url ', function() {
144+
expect(urlProtocolFilter('www.google.com')).to.be.equal('http://www.google.com');
145+
});
146+
it('should not add anything to the url ', function() {
147+
expect(urlProtocolFilter('http://google.com')).to.be.equal('http://google.com');
148+
});
149+
it('should not add anything to the url ', function() {
150+
expect(urlProtocolFilter('https://google.com')).to.be.equal('https://google.com');
151+
});
152+
});
138153
});

app/filters/url-protocol.filter.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
(function() {
2+
'use strict';
3+
4+
angular.module('topcoder').filter('urlProtocol', urlProtocol);
5+
6+
function urlProtocol() {
7+
return function(link) {
8+
if (!link) {
9+
return link;
10+
}
11+
var result;
12+
var startingUrl = "http://";
13+
var httpsStartingUrl = "https://";
14+
if(link.indexOf(startingUrl) === 0||link.indexOf(httpsStartingUrl) === 0) {
15+
result = link;
16+
} else {
17+
result = startingUrl + link;
18+
}
19+
return result;
20+
};
21+
}
22+
23+
})();

app/index.jade

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ html
232232
script(src="filters/track.filter.js")
233233
script(src="filters/truncate.filter.js")
234234
script(src="filters/underscore-strip.filter.js")
235+
script(src="filters/url-protocol.filter.js")
235236
script(src="layout/layout.module.js")
236237
script(src="layout/header/header.controller.js")
237238
script(src="my-challenges/my-challenges.module.js")

0 commit comments

Comments
 (0)