Clickable Links in Q and A
According to strategy, links shall be clickable in Q and A module
- Everyone can post clickable links
- Check with RegEx or use other technique to securely parse links from questions and answers
- It should open a dialog: body: "Sie verlassen jetzt tinyCampus, sicher zur externen Seite navigieren? ", header: "Externe Seite aufrufen", options: [Abbrechen] | [Weiter],
https://stackoverflow.com/questions/51985111/how-to-linkify-text-in-flutter
@rapl42 it doesn't seem like there's a good way to use Uri to parse strings for 0-n URLs. However, it can detect if there's a valid URI inside a string. Maybe there's a function i didn't see yet.
linkify RegEx:
final _urlRegex = RegExp(
r'^((?:.|\n)*?)((?:https?):\/\/[^\s/$.?#].[^\s]*)',
caseSensitive: false,
);
final _looseUrlRegex = RegExp(
r'^((?:.|\n)*?)([^\s]*\.[^\s]*)',
caseSensitive: false,
);
I came up with those RegEx:
the first one is an extension to a stackoverflow-answer. I added "[^\s\\]*" so that &someValue=1 will be parsed to. Optimization needed here.
String urlRawString =
r'(?:(?:https?|ftp):\/\/)?[\w/\-?=%.]+\.[\w/\-?=%.]+[^\s\\]*';
String mailRawString = r'\S+@\S+';
String telRawString = r'[\d-]{9,}';
https://stackoverflow.com/questions/51985111/how-to-linkify-text-in-flutter
i'm using splintor's code so far to test it in order to not add another dependency. I know RegEx is not the best solution, we need to take a deeper look into flutter/dart classes.
We talked about the design and it was not liked, changed it back to a more standard approach: