Enable links beginning with 'www.' even if no protocol is specified

This commit is contained in:
Jonas Jenwald 2013-10-16 00:12:23 +02:00
parent 7ad19c3355
commit fb52144cfb

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;