summaryrefslogtreecommitdiff
path: root/data/extensions/https-everywhere@eff.org/background-scripts/util.js
diff options
context:
space:
mode:
authorRuben Rodriguez <ruben@trisquel.info>2022-09-08 20:18:54 -0400
committerRuben Rodriguez <ruben@trisquel.info>2022-09-08 20:18:54 -0400
commit5da28b0f8771834ae208d61431d632875e9f8e7d (patch)
tree688ecaff26197bad8abde617b4947b11d617309e /data/extensions/https-everywhere@eff.org/background-scripts/util.js
parent4a87716686104266a9cccc2d83cc249e312f3673 (diff)
Updated extensions:
* Upgraded Privacy Redirect to 1.1.49 and configured to use the 10 most reliable invidious instances * Removed ViewTube * Added torproxy@icecat.gnu based on 'Proxy toggle' extension * Added jShelter 0.11.1 * Upgraded LibreJS to 7.21.0 * Upgraded HTTPS Everywhere to 2021.7.13 * Upgraded SubmitMe to 1.9
Diffstat (limited to 'data/extensions/https-everywhere@eff.org/background-scripts/util.js')
-rw-r--r--data/extensions/https-everywhere@eff.org/background-scripts/util.js23
1 files changed, 21 insertions, 2 deletions
diff --git a/data/extensions/https-everywhere@eff.org/background-scripts/util.js b/data/extensions/https-everywhere@eff.org/background-scripts/util.js
index 5a4097c..e2b069b 100644
--- a/data/extensions/https-everywhere@eff.org/background-scripts/util.js
+++ b/data/extensions/https-everywhere@eff.org/background-scripts/util.js
@@ -62,11 +62,16 @@ function loadExtensionFile(url, returnType) {
/**
* Remove tailing dots from hostname, e.g. "www.example.com."
+ * Preserve port numbers if they are used
*/
-function getNormalisedHostname(hostname) {
+function getNormalisedHostname(host) {
+ let [ hostname, port ] = host.split(":");
while (hostname && hostname[hostname.length - 1] === '.' && hostname !== '.') {
hostname = hostname.slice(0, -1);
}
+ if (port) {
+ return `${hostname}:${port}`;
+ }
return hostname;
}
@@ -143,6 +148,19 @@ function ArrayBufferToString(ab) {
return string;
}
+/**
+ * Convert a string to an ArrayBuffer
+ *
+ * @param string: a string to convert
+ */
+function StringToArrayBuffer(str) {
+ var byteArray = new Uint8Array(str.length);
+ for (var i = 0; i < str.length; i++) {
+ byteArray[i] = str.charCodeAt(i);
+ }
+ return byteArray;
+}
+
Object.assign(exports, {
VERB,
@@ -158,7 +176,8 @@ Object.assign(exports, {
setDefaultLogLevel,
getDefaultLogLevel,
loadExtensionFile,
- ArrayBufferToString
+ ArrayBufferToString,
+ StringToArrayBuffer
});
})(typeof exports == 'undefined' ? require.scopes.util = {} : exports);