diff options
Diffstat (limited to 'lib/utils/location.js')
-rw-r--r-- | lib/utils/location.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/utils/location.js b/lib/utils/location.js index 84a71ad..1afe415 100644 --- a/lib/utils/location.js +++ b/lib/utils/location.js @@ -4,7 +4,16 @@ var path = require('path'); // Is the url an external url function isExternal(href) { try { - return Boolean(url.parse(href).protocol); + return Boolean(url.parse(href).protocol) && !isDataURI(href); + } catch(err) { + return false; + } +} + +// Is the url an iniline data-uri +function isDataURI(href) { + try { + return Boolean(url.parse(href).protocol) && (url.parse(href).protocol === 'data:'); } catch(err) { return false; } @@ -39,7 +48,7 @@ function normalize(s) { @return {String} */ function toAbsolute(_href, dir, outdir) { - if (isExternal(_href)) return _href; + if (isExternal(_href) || isDataURI(_href)) return _href; outdir = outdir == undefined? dir : outdir; _href = normalize(_href); @@ -97,6 +106,7 @@ function areIdenticalPaths(p1, p2) { module.exports = { areIdenticalPaths: areIdenticalPaths, + isDataURI: isDataURI, isExternal: isExternal, isRelative: isRelative, isAnchor: isAnchor, |