Skip to content

Commit

Permalink
SAK-50554 Site Import Fails to Import Some Embedded Images
Browse files Browse the repository at this point in the history
  • Loading branch information
st-manu committed Oct 1, 2024
1 parent 2bab69c commit 83ec5c7
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
public class LinkMigrationHelperImpl implements LinkMigrationHelper {
private static final String ESCAPED_SPACE= "%"+"20";
private static final String[] shortenerDomainsToExpand = {"/x/", "bit.ly"};
private static final String[] encodedImage = {"data:image"};

private ServerConfigurationService serverConfigurationService;

Expand Down Expand Up @@ -192,8 +193,8 @@ private String expandShortenedUrls(String msgBody){
}

for(String reference : references){
//If doesn't contain the prefix /x/, should ignore the URL.
if(referenceContainsShortenerDomains(reference)){
//If doesn't contain the prefix /x/ or is an encoded image, should ignore the URL.
if(!referenceContainsEncodedImage(reference) && referenceContainsShortenerDomains(reference)){
String longUrl = this.expandShortenedUrl(reference);
replacedBody = StringUtils.replace(replacedBody, reference, longUrl);
}
Expand All @@ -202,6 +203,10 @@ private String expandShortenedUrls(String msgBody){
return replacedBody;
}

private boolean referenceContainsEncodedImage(String reference) {
return Arrays.stream(encodedImage).anyMatch(reference::contains);
}

private boolean referenceContainsShortenerDomains(String reference) {
return Arrays.stream(shortenerDomainsToExpand).anyMatch(reference::contains);
}
Expand Down

0 comments on commit 83ec5c7

Please sign in to comment.