Merge pull request #3744 from Snuffleupagus/enable-www-links

Enable links beginning with 'www.' even if no protocol is specified
This commit is contained in:
Brendan Dahl 2013-10-30 10:32:22 -07:00
commit f72fad9a1a

View File

@ -616,7 +616,7 @@ var LinkAnnotation = (function LinkAnnotationClosure() {
if (action) {
var linkType = action.get('S').name;
if (linkType === 'URI') {
var url = action.get('URI');
var url = addDefaultProtocolToUrl(action.get('URI'));
// TODO: pdf spec mentions urls can be relative to a Base
// entry in the dictionary.
if (!isValidUrl(url, false)) {
@ -652,6 +652,14 @@ var LinkAnnotation = (function LinkAnnotationClosure() {
}
}
// Lets URLs beginning with 'www.' default to using the 'http://' protocol.
function addDefaultProtocolToUrl(url) {
if (url.indexOf('www.') === 0) {
return ('http://' + url);
}
return url;
}
Util.inherit(LinkAnnotation, Annotation, {
hasOperatorList: function LinkAnnotation_hasOperatorList() {
return false;