question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Smidge interfering with 'asp-append-version' tag helper creating duplicate src attributes

See original GitHub issue

If I use asp-append-version on a script tag in a project which includes Smidge 4.0.4 it results in markup with two src attributes, for example.

Script reference:

<script src="~/main.js" asp-append-version="true"></script>

Markup (view source):

<script src="/main.js?v=xtltRP-8iJXgGK7LWJBGthatLEu0oYmDmTR3iRmR7ho" src="/main.js"></script>

This will fail W3C validation. It also interferes with a sites content security policy causing nonce attributes added to the tag to be ignored (due to the duplicate src).

Haven’t tested but I imagine the problem will be there with other tag helpers targeting script src attribute.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Shazwazzacommented, May 4, 2022

This will be released with 4.1.0 soon

1reaction
Shazwazzacommented, May 4, 2022

I’ve pushed a fix for this. Now Smidge will validate if there are asp- attributes on script/link tags when trying to render a Smidge bundle and if there are it will throw an InvalidOperationException because these attributes from the Script/Link TagHelper will not work or be compatible with Smidge bundles.

If the script/link src/href is not a Smidge bundle, then it will just let the default Script/Link tag helpers execute as per normal. This was what was attempted to be done before but because the Smidge Script/Link tag helpers have their own src/href attributes, it would end up adding 2x to the output causing this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Asp.NET Core custom Input Tag Helper rendering ...
Since it creates it differently, it doesn't do a merge of the attributes to avoid duplicates, but creates them again.
Read more >
Image Tag Helper in ASP.NET Core
When asp-append-version is specified with a true value along with a src attribute, the Image Tag Helper is invoked.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found