Skip to content

Commit

Permalink
LPD-38847 if there is no friendlyURL inserted on the creation of the …
Browse files Browse the repository at this point in the history
…web content and the title has trailing slashes on it, remove them
  • Loading branch information
AliciaGarciaGarcia authored and brianchandotcom committed Oct 11, 2024
1 parent 71fb511 commit bf0fa9f
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
import com.liferay.osgi.service.tracker.collections.list.ServiceTrackerListFactory;
import com.liferay.petra.sql.dsl.DSLFunctionFactoryUtil;
import com.liferay.petra.sql.dsl.DSLQueryFactoryUtil;
import com.liferay.petra.string.CharPool;
import com.liferay.petra.string.StringBundler;
import com.liferay.petra.string.StringPool;
import com.liferay.portal.aop.AopService;
Expand Down Expand Up @@ -7421,7 +7422,7 @@ private Map<Locale, String> _checkFriendlyURLMap(
}

return HashMapBuilder.put(
defaultLocale, titleMap.get(defaultLocale)
defaultLocale, _removeTrailingSlashes(titleMap.get(defaultLocale))
).build();
}

Expand Down Expand Up @@ -8111,6 +8112,20 @@ private void _removeDDMFormFieldValues(
}
}

private String _removeTrailingSlashes(String title) {
if (Validator.isNull(title) || !title.endsWith(StringPool.SLASH)) {
return title;
}

int end = title.length();

while ((end > 0) && (title.charAt(end - 1) == CharPool.SLASH)) {
end--;
}

return title.substring(0, end);
}

private String _replaceTempImages(JournalArticle article, String content)
throws PortalException {

Expand Down

0 comments on commit bf0fa9f

Please sign in to comment.