Actions
Defect #42588
openGenerated SVG sprite icon URL does not include digest when rendered in a JSON response
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Affected version:
Description
The sprite_icon
method generally generates a SVG tag as below:
<svg class="s18 icon-svg" aria-hidden="true">
<use href="/assets/icons-35b4b65e.svg#icon--add"></use>
</svg>
But when rendered via render json:
, the use
tag's href
does not contain the digest:
{
"id": 1234,
"label": "Assignment #1234: Test issue",
"value": 1234
"icon": "<svg class=\"s18 icon-svg\" aria-hidden=\"true\"><use href=\"/icons.svg#icon--issue\"></use></svg>"
}
I have attached a patch file to patch the AutoCompletesController
to reproduce the bug. After applying the patch, trigger an issue autocomplete and check the response.
Files
Updated by Marius BĂLTEANU 5 days ago
- Status changed from New to Needs feedback
asset_path
is not available in the controller, is an Action View helper.
I think the best way is to render the json from a view, to access the path using ActionController::Base.helpers.asset_path('<path_to_image>')
or to move the method to a helper where you can include include ActionView::Helpers::AssetUrlHelper
.
Please let me know if you fixed your issue.
Actions