From fb52144cfbac1ccf7026132136e6157f10856509 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 16 Oct 2013 00:12:23 +0200 Subject: [PATCH] Enable links beginning with 'www.' even if no protocol is specified --- src/shared/annotation.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/shared/annotation.js b/src/shared/annotation.js index d16898f91..8d0630219 100644 --- a/src/shared/annotation.js +++ b/src/shared/annotation.js @@ -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;