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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user