chat: strictly match URLs in outgoing strings

Our regex processes true, and sends a message as a URL, if any part of
the string is a URL starting with a URI schema.
We pass this function strings cut up by spaces. If a link was enclosed
in quotes, or in brackets, this would still process as true.

This adds ^ to the regex to only process strings that START with
a schema.
This commit is contained in:
Matilde Park 2020-04-27 21:16:10 -04:00
parent 3196179fbd
commit 5b45ad986d

View File

@ -173,7 +173,7 @@ export class ChatInput extends Component {
isUrl(string) {
try {
const websiteTest = new RegExp(String(/((\w+:\/\/)[-a-zA-Z0-9:@;?&=\/%\+\.\*!'\(\),\$_\{\}\^~\[\]`#|]+)/.source)
const websiteTest = new RegExp(String(/^((\w+:\/\/)[-a-zA-Z0-9:@;?&=\/%\+\.\*!'\(\),\$_\{\}\^~\[\]`#|]+)/.source)
);
return websiteTest.test(string);
} catch (e) {