Add logic to parse and remove any instances of https://twitter.com by replacing with user's preference

The issue was happening since the original regex is checking for href tags only, so I tried a simpler approach of searching for https://twitter.com instead whenever the regex does not match the input string

Add Nodemon package to dev dependencies for local debugging
This commit is contained in:
Anshuman Kumar 2022-12-29 20:19:58 +05:30
parent 22b63a3415
commit c71bf6ee48
4 changed files with 904 additions and 190 deletions

View File

@ -261,8 +261,14 @@ module.exports = function(request, fs) {
str = str.replace(youtubeRegex, protocol + user_preferences.domain_youtube) 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){
str = str.replace(twitterRegex, protocol + user_preferences.domain_twitter) if (twitterRegex.test(str)){
str = str.replace(twitterRegex, protocol + user_preferences.domain_twitter)
}
else {
str = str.replace('https://twitter.com',protocol + user_preferences.domain_twitter)
}
}
if(typeof(user_preferences.domain_instagram) != 'undefined') if(typeof(user_preferences.domain_instagram) != 'undefined')
if(user_preferences.domain_instagram) if(user_preferences.domain_instagram)

View File

@ -210,7 +210,7 @@ module.exports = function() {
} }
comments_html += replies_html + '</details></div>' comments_html += replies_html + '</details></div>'
} else { } else {
if(comment.children.length > 0) { if(comment.children.length > 0) {
let parent_id = comment.parent_id.split('_')[1] let parent_id = comment.parent_id.split('_')[1]
let load_comms_href = parent_id let load_comms_href = parent_id

1075
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,8 @@
}, },
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js" "start": "node app.js",
"dev": "nodemon app.js"
}, },
"dependencies": { "dependencies": {
"compression": "^1.7.4", "compression": "^1.7.4",
@ -34,5 +35,7 @@
"pug": "^3.0.2", "pug": "^3.0.2",
"redis": "^3.1.2" "redis": "^3.1.2"
}, },
"devDependencies": {} "devDependencies": {
"nodemon": "^2.0.20"
}
} }