Update regex to find a match and replace if present
This commit is contained in:
parent
c71bf6ee48
commit
f7f2d0beec
|
@ -257,8 +257,14 @@ module.exports = function(request, fs) {
|
||||||
return str
|
return str
|
||||||
|
|
||||||
if(typeof(user_preferences.domain_youtube) != 'undefined')
|
if(typeof(user_preferences.domain_youtube) != 'undefined')
|
||||||
if(user_preferences.domain_youtube)
|
if(user_preferences.domain_youtube){
|
||||||
|
if (youtubeRegex.test(str)){
|
||||||
str = str.replace(youtubeRegex, protocol + user_preferences.domain_youtube)
|
str = str.replace(youtubeRegex, protocol + user_preferences.domain_youtube)
|
||||||
|
} else {
|
||||||
|
youtubeRegex = /(https?:\/\/)([A-z.]+\.)?youtu(be\.com|\.be)(?=.+)/gm;
|
||||||
|
str = str.replace(youtubeRegex, protocol + user_preferences.domain_youtube)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(typeof(user_preferences.domain_twitter) != 'undefined')
|
if(typeof(user_preferences.domain_twitter) != 'undefined')
|
||||||
if(user_preferences.domain_twitter){
|
if(user_preferences.domain_twitter){
|
||||||
|
@ -266,7 +272,8 @@ module.exports = function(request, fs) {
|
||||||
str = str.replace(twitterRegex, protocol + user_preferences.domain_twitter)
|
str = str.replace(twitterRegex, protocol + user_preferences.domain_twitter)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
str = str.replace('https://twitter.com',protocol + user_preferences.domain_twitter)
|
twitterRegex = /(https?:\/\/)(www\.)?twitter\.com(?=.)/gm;
|
||||||
|
str = str.replace(twitterRegex, protocol + user_preferences.domain_twitter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue