|
8 | 8 | import com.liferay.petra.string.StringBundler; |
9 | 9 | import com.liferay.petra.string.StringPool; |
10 | 10 | import com.liferay.portal.kernel.content.security.policy.ContentSecurityPolicyNonceProviderUtil; |
| 11 | +import com.liferay.portal.kernel.exception.PortalException; |
| 12 | +import com.liferay.portal.kernel.frontend.hashed.files.HashedFilesRegistryUtil; |
11 | 13 | import com.liferay.portal.kernel.model.Portlet; |
12 | 14 | import com.liferay.portal.kernel.servlet.FileAvailabilityUtil; |
13 | 15 | import com.liferay.portal.kernel.servlet.taglib.BodyContentWrapper; |
14 | 16 | import com.liferay.portal.kernel.servlet.taglib.aui.ScriptData; |
| 17 | +import com.liferay.portal.kernel.util.PortalUtil; |
15 | 18 | import com.liferay.portal.kernel.util.Validator; |
16 | 19 | import com.liferay.portal.kernel.util.WebKeys; |
17 | 20 | import com.liferay.taglib.aui.base.BaseScriptTag; |
@@ -265,7 +268,34 @@ private int _endTag() throws IOException, JspException { |
265 | 268 | _write(jspWriter, "id", getId()); |
266 | 269 | _write(jspWriter, "integrity", getIntegrity()); |
267 | 270 | _write(jspWriter, "referrerpolicy", getReferrerPolicy()); |
268 | | - _write(jspWriter, "src", getSrc()); |
| 271 | + |
| 272 | + String src = getSrc(); |
| 273 | + |
| 274 | + if (getHashedFile()) { |
| 275 | + StringBundler sb = new StringBundler(3); |
| 276 | + |
| 277 | + try { |
| 278 | + sb.append(PortalUtil.getCDNHost(getRequest())); |
| 279 | + } |
| 280 | + catch (PortalException portalException) { |
| 281 | + throw new RuntimeException(portalException); |
| 282 | + } |
| 283 | + |
| 284 | + sb.append(PortalUtil.getPathProxy()); |
| 285 | + |
| 286 | + String unhashedFileURI = |
| 287 | + PortalUtil.getPathModule() + StringPool.SLASH + getSrc(); |
| 288 | + |
| 289 | + String hashedFileURI = HashedFilesRegistryUtil.getHashedFileURI( |
| 290 | + unhashedFileURI); |
| 291 | + |
| 292 | + sb.append( |
| 293 | + (hashedFileURI == null) ? unhashedFileURI : hashedFileURI); |
| 294 | + |
| 295 | + src = sb.toString(); |
| 296 | + } |
| 297 | + |
| 298 | + _write(jspWriter, "src", src); |
269 | 299 | _write(jspWriter, "type", getType()); |
270 | 300 |
|
271 | 301 | String senna = getSenna(); |
|
0 commit comments