Skip to content

Commit

Permalink
Merge pull request #3712 from mobun/fix/3711
Browse files Browse the repository at this point in the history
Fix for #3711
  • Loading branch information
wobba authored May 7, 2024
2 parents 54b6147 + fd7909f commit e889dd4
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ export default class SearchResultsContainer extends React.Component<ISearchResul
}
}

if (!this.isOnlineDomain(item[AutoCalculatedDataSourceFields.AutoPreviewImageUrl])) {
if (!this.isM365Source(item[AutoCalculatedDataSourceFields.AutoPreviewImageUrl]) && !this.isOnlineDomain(item[AutoCalculatedDataSourceFields.AutoPreviewImageUrl])) {
item[AutoCalculatedDataSourceFields.AutoPreviewImageUrl] = null;
}
return item;
Expand All @@ -420,6 +420,19 @@ export default class SearchResultsContainer extends React.Component<ISearchResul
return !isEmpty(url) && url.toLocaleLowerCase().indexOf(window.location.hostname.split('.').slice(-2).join('.').toLocaleLowerCase()) !== -1;
}

/**
* Check if picture is deliverd from a M365 Source
* @param url
*/
private isM365Source(url: string) {
const cdnDomains:RegExp[] = [/^https?:\/\/(?:[A-Za-z0-9,-]+\.)+office\.net.*/,
/^https?:\/\/(?:[A-Za-z0-9,-]+\.)+sharepointonline\.com.*/,
/^https?:\/\/(?:[A-Za-z0-9,-]+\.)+sharepoint\.us.*/,
/^https?:\/\/(?:[A-Za-z0-9,-]+\.)+sharepoint-mil\.us.*/,
];
return cdnDomains.some(regex => regex.test(url))
}

/**
* Extracts the GUID value from a string
* @param value the string value containing a GUID
Expand Down

0 comments on commit e889dd4

Please sign in to comment.