diff --git a/inc/commons.js b/inc/commons.js index 6acbab6..aebc2e0 100644 --- a/inc/commons.js +++ b/inc/commons.js @@ -257,25 +257,45 @@ module.exports = function(request, fs) { return str if(typeof(user_preferences.domain_youtube) != 'undefined') - if(user_preferences.domain_youtube) - str = str.replace(youtubeRegex, protocol + user_preferences.domain_youtube) + if(user_preferences.domain_youtube){ + if (!youtubeRegex.test(str)){ + 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(user_preferences.domain_twitter) + if(user_preferences.domain_twitter){ + if (!twitterRegex.test(str)){ + twitterRegex = /(https?:\/\/)(www\.)?twitter\.com(?=.)/gm; + } str = str.replace(twitterRegex, protocol + user_preferences.domain_twitter) + } - if(typeof(user_preferences.domain_instagram) != 'undefined') - if(user_preferences.domain_instagram) - str = str.replace(instagramRegex, protocol + user_preferences.domain_instagram) - - if(typeof(user_preferences.domain_quora) != 'undefined') - if(user_preferences.domain_quora) + if(typeof(user_preferences.domain_instagram) != 'undefined'){ + if(user_preferences.domain_instagram){ + if (!instagramRegex.test(str)){ + instagramRegex = /(https?:\/\/)(www+\.)?instagram.com(?=.)/gm; + } + str = str.replace(instagramRegex, protocol + user_preferences.domain_instagram); + } + } + if(typeof(user_preferences.domain_quora) != 'undefined'){ + if(user_preferences.domain_quora){ + if (!quoraRegex.test(str)){ + quoraRegex = /(https?:\/\/)([A-z.]+\.)?quora\.com(?=.)/gm; + } str = str.replace(quoraRegex, protocol + user_preferences.domain_quora) - - if(typeof(user_preferences.domain_imgur) != 'undefined') - if(user_preferences.domain_imgur) + } + } + if(typeof(user_preferences.domain_imgur) != 'undefined'){ + if(user_preferences.domain_imgur){ + if (!imgurRegex.test(str)){ + imgurRegex = /(https?:\/{2})([im]\.)?(stack\.)?imgur\.(com|io)(?=.)/gm; + } str = str.replace(imgurRegex, protocol + user_preferences.domain_imgur) - + } + } return str } diff --git a/inc/compilePostComments.js b/inc/compilePostComments.js index 98d3584..2eb0989 100644 --- a/inc/compilePostComments.js +++ b/inc/compilePostComments.js @@ -210,7 +210,7 @@ module.exports = function() { } comments_html += replies_html + '' } else { - if(comment.children.length > 0) { + if(comment.children.length > 0) { let parent_id = comment.parent_id.split('_')[1] let load_comms_href = parent_id diff --git a/package.json b/package.json index 78780c6..46634fd 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "start": "node app.js" + "start": "node app.js", + "dev": "nodemon app.js" }, "dependencies": { "compression": "^1.7.4", @@ -34,5 +35,7 @@ "pug": "^3.0.2", "redis": "^3.1.2" }, - "devDependencies": {} + "devDependencies": { + "nodemon": "^2.0.20" + } }