1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-11-03 17:13:05 +00:00

Extend encodeuricomponent to process additional characters (#7128)

* First commit

* Fix version number in docs

* Add code comment
This commit is contained in:
Jeremy Ruston
2023-01-19 17:45:54 +00:00
committed by GitHub
parent a3a1eceb4a
commit a5894946de
11 changed files with 28 additions and 12 deletions

View File

@@ -685,6 +685,16 @@ exports.escapeRegExp = function(s) {
return s.replace(/[\-\/\\\^\$\*\+\?\.\(\)\|\[\]\{\}]/g, '\\$&');
};
/*
Extended version of encodeURIComponent that encodes additional characters including
those that are illegal within filepaths on various platforms including Windows
*/
exports.encodeURIComponentExtended = function(s) {
return encodeURIComponent(s).replace(/[!'()*]/g,function(c) {
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
});
};
// Checks whether a link target is external, i.e. not a tiddler title
exports.isLinkExternal = function(to) {
var externalRegExp = /^(?:file|http|https|mailto|ftp|irc|news|obsidian|data|skype):[^\s<>{}\[\]`|"\\^]+(?:\/|\b)/i;