2016-10-18 08:18:32 +00:00
|
|
|
/*\
|
|
|
|
title: $:/core/modules/filters/decodeuricomponent.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: filteroperator
|
|
|
|
|
|
|
|
Filter operator for applying decodeURIComponent() to each item.
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/*
|
|
|
|
Export our filter functions
|
|
|
|
*/
|
|
|
|
|
2023-02-02 09:55:54 +00:00
|
|
|
exports.decodebase64 = function(source,operator,options) {
|
|
|
|
var results = [];
|
2023-10-18 15:08:56 +00:00
|
|
|
var binary = operator.suffixes && operator.suffixes.indexOf("binary") !== -1;
|
|
|
|
var urlsafe = operator.suffixes && operator.suffixes.indexOf("urlsafe") !== -1;
|
2023-02-02 09:55:54 +00:00
|
|
|
source(function(tiddler,title) {
|
2023-10-18 15:08:56 +00:00
|
|
|
results.push($tw.utils.base64Decode(title,binary,urlsafe));
|
2023-02-02 09:55:54 +00:00
|
|
|
});
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.encodebase64 = function(source,operator,options) {
|
|
|
|
var results = [];
|
2023-10-18 15:08:56 +00:00
|
|
|
var binary = operator.suffixes && operator.suffixes.indexOf("binary") !== -1;
|
|
|
|
var urlsafe = operator.suffixes && operator.suffixes.indexOf("urlsafe") !== -1;
|
2023-02-02 09:55:54 +00:00
|
|
|
source(function(tiddler,title) {
|
2023-10-18 15:08:56 +00:00
|
|
|
results.push($tw.utils.base64Encode(title,binary,urlsafe));
|
2023-02-02 09:55:54 +00:00
|
|
|
});
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
2016-10-18 08:18:32 +00:00
|
|
|
exports.decodeuricomponent = function(source,operator,options) {
|
|
|
|
var results = [];
|
|
|
|
source(function(tiddler,title) {
|
2021-08-29 12:39:32 +00:00
|
|
|
results.push($tw.utils.decodeURIComponentSafe(title));
|
2016-10-18 08:18:32 +00:00
|
|
|
});
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.encodeuricomponent = function(source,operator,options) {
|
|
|
|
var results = [];
|
|
|
|
source(function(tiddler,title) {
|
2023-01-19 17:45:54 +00:00
|
|
|
results.push($tw.utils.encodeURIComponentExtended(title));
|
2016-10-18 08:18:32 +00:00
|
|
|
});
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.decodeuri = function(source,operator,options) {
|
|
|
|
var results = [];
|
|
|
|
source(function(tiddler,title) {
|
2021-08-29 12:39:32 +00:00
|
|
|
results.push($tw.utils.decodeURISafe(title));
|
2016-10-18 08:18:32 +00:00
|
|
|
});
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.encodeuri = function(source,operator,options) {
|
|
|
|
var results = [];
|
|
|
|
source(function(tiddler,title) {
|
|
|
|
results.push(encodeURI(title));
|
|
|
|
});
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.decodehtml = function(source,operator,options) {
|
|
|
|
var results = [];
|
|
|
|
source(function(tiddler,title) {
|
|
|
|
results.push($tw.utils.htmlDecode(title));
|
|
|
|
});
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.encodehtml = function(source,operator,options) {
|
|
|
|
var results = [];
|
|
|
|
source(function(tiddler,title) {
|
|
|
|
results.push($tw.utils.htmlEncode(title));
|
|
|
|
});
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.stringify = function(source,operator,options) {
|
|
|
|
var results = [];
|
|
|
|
source(function(tiddler,title) {
|
2020-12-04 13:19:59 +00:00
|
|
|
results.push($tw.utils.stringify(title,(operator.suffix === "rawunicode")));
|
2016-10-18 08:18:32 +00:00
|
|
|
});
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
2017-10-29 15:53:53 +00:00
|
|
|
exports.jsonstringify = function(source,operator,options) {
|
|
|
|
var results = [];
|
|
|
|
source(function(tiddler,title) {
|
2020-12-04 13:19:59 +00:00
|
|
|
results.push($tw.utils.jsonStringify(title,(operator.suffix === "rawunicode")));
|
2017-10-29 15:53:53 +00:00
|
|
|
});
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
2016-10-18 08:18:32 +00:00
|
|
|
exports.escaperegexp = function(source,operator,options) {
|
|
|
|
var results = [];
|
|
|
|
source(function(tiddler,title) {
|
|
|
|
results.push($tw.utils.escapeRegExp(title));
|
|
|
|
});
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
2019-06-26 11:32:01 +00:00
|
|
|
exports.escapecss = function(source,operator,options) {
|
|
|
|
var results = [];
|
|
|
|
source(function(tiddler,title) {
|
|
|
|
// escape any character with a special meaning in CSS using CSS.escape()
|
2021-04-02 08:25:01 +00:00
|
|
|
results.push($tw.utils.escapeCSS(title));
|
2019-06-26 11:32:01 +00:00
|
|
|
});
|
|
|
|
return results;
|
|
|
|
};
|
|
|
|
|
2016-10-18 08:18:32 +00:00
|
|
|
})();
|