This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- appendAnchor.js.bak 2010-09-23 12:03:00.000000000 +0900 | |
+++ appendAnchor.js 2010-09-23 12:23:29.000000000 +0900 | |
@@ -36,7 +36,7 @@ | |
// Array.prototype.uniq = function() this.reduceRight( function (a, b) (a[0] === b || a.unshift(b), a), []); | |
// [ 'TITLE', 'STYLE', 'SCRIPT', 'TEXTAREA', 'XMP', 'A', ].join('').split('').sort().uniq().join(''); | |
const xpathQueryPlainText = '/descendant::*[not(contains(" TITLE STYLE SCRIPT TEXTAREA XMP A ", concat(" ", translate(local-name(), "aceilmprstxy", "ACEILMPRSTXY"), " ")))]/child::text()'; | |
- const regexpLikeURL = new RegExp("h?(ttps?):/+([a-zA-Z0-9][-_.!~*'()a-zA-Z0-9;/?:@&=+$,%#]+[-_~*(a-zA-Z0-9;/?@&=+$%#])"); | |
+ const regexpLikeURL = new RegExp("(h?ttps?|ftp):/+([a-zA-Z0-9][-_.!~*'()a-zA-Z0-9;/?:@&=+$,%#]+[-_~*(a-zA-Z0-9;/?@&=+$%#])"); | |
// process global variable | |
if (stringToBoolean(liberator.globalVariables.auto_append_anchor, false)) { | |
@@ -72,11 +72,13 @@ | |
result++; | |
// build URL | |
- let href = 'h' + RegExp.$1 + '://' + RegExp.$2; | |
+ let scheme = RegExp.$1, host = RegExp.$2, lastMatch = RegExp.lastMatch; | |
+ if (/^ttps?$/(scheme)) scheme = 'h' + scheme; | |
+ let href = scheme + '://' + host; | |
// reset range | |
range.setStart(node, start); | |
- range.setEnd(node, start + RegExp.lastMatch.length); | |
+ range.setEnd(node, start + lastMatch.length); | |
// build anchor element | |
let anchor = doc.createElement('a'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment