Umbraco 13 RTE Validate Link on Save

Hi,

Is there any way to check any links any one put in using the RTE to make sure they are the correct format.

The reason I am asking is I have developed a Media handler and found that some of our staff are adding links like this:

media/uwvbo2ok/register-of-interests.pdf

But when it comes to the media handler that check the Media Item to see if it in use it not detecting it on a page

But if the Link is formatted like this:

{localLink:umb://media/7117abbd4eca4a27bd818b6025db341c}

Then my media handler works as expected.

here a sample of the code I am using to get the media and it relations:

IMedia media = _MediaService.GetMediaByPath(x.Path.ToString());

relations = _relationService.GetByChildId(media.Id);

This works as long as the link is formatted using

{localLink:umb://media/7117abbd4eca4a27bd818b6025db341c}

But if formatted the other way then it dose not work.

Can any one suggest what wrong!

Thanks

I’m not sure if I fully understand your question but could you not write a regex query to test if the link exists in the format? Similar to

var umbUrlRegex = new Regex(@"^localLink:umb://media", RegexOptions.IgnoreCase);

If this matches then an entry has been found?