Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
d-gibbs opened this issue Apr 29, 2022 · 5 comments
Labels
Milestone

Comments

@d-gibbs
Copy link

d-gibbs commented Apr 29, 2022

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.

@Shazwazza
Copy link
Owner

I can confirm this but I also get a unhandled exception when trying this. It is to do with conflicts with the normal ScriptTagHelper. Smidge will need to adjust it's own to ignore all processing if other asp script tag helper attributes are applied.

@Shazwazza Shazwazza added the bug label May 3, 2022
@Shazwazza Shazwazza added this to the 4.1.0 milestone May 4, 2022
@Shazwazza
Copy link
Owner

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.

@Shazwazza
Copy link
Owner

This will be released with 4.1.0 soon

@d-gibbs
Copy link
Author

d-gibbs commented May 4, 2022

Amazing, thanks for the quick fix!

@Shazwazza
Copy link
Owner

That's pushed to Nuget now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants