SharePoint 2013 URL Trailing Slash causes Video to disappear

It was like every other Monday in my work life.
I got a call that started like this: “SharePoint is not working…”
Well…after 10 minutes I got a more precise description of the problem and I found the issue kind of funny and share worthy.

Background

We developed a Web Part that aggregates News using SharePoint Search.

Issue Description

A User created a new “News Article Page” and added a Video Web Part to it. Everything was working fine. This new page was picked up by the SharePoint Search Crawler and displayed in the Web Part we created. When a user clicked on the Link to the News Article Page the page was rendered fine except that the video was gone.

Solution

Obviously 😉 I first compared the two URLs and I found a trailing slash (/) in the URL that came from the Web Part. When I removed it everything worked fine. The “Path” Attribute you get from the search result has always a slash (/) at the end. I just fixed the source code by adding a .TrimEnd(‘/’) to the URL String and everything worked great.