mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 19:15:58 +01:00 
			
		
		
		
	fix: don't count internal links towards link count when restricting new users from posting links
This commit is contained in:
		| @@ -96,9 +96,16 @@ module.exports = function (Posts) { | |||||||
|  |  | ||||||
| 		if (!isPrivileged && reputation < meta.config['min:rep:post-links']) { | 		if (!isPrivileged && reputation < meta.config['min:rep:post-links']) { | ||||||
| 			const parsed = await plugins.hooks.fire('filter:parse.raw', String(content)); | 			const parsed = await plugins.hooks.fire('filter:parse.raw', String(content)); | ||||||
| 			if (parsed.match(/<a[^>]*>([^<]+)<\/a>/g)) { | 			const matches = parsed.matchAll(/<a[^>]*href="([^"]+)"[^>]*>/g); | ||||||
| 				return false; | 			let external = 0; | ||||||
|  | 			for (const [, href] of matches) { | ||||||
|  | 				const internal = utils.isInternalURI(new URL(href, nconf.get('url')), new URL(nconf.get('url')), nconf.get('relative_path')); | ||||||
|  | 				if (!internal) { | ||||||
|  | 					external += 1; | ||||||
|  | 				} | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
|  | 			return external === 0; | ||||||
| 		} | 		} | ||||||
| 		return true; | 		return true; | ||||||
| 	}; | 	}; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user