Skip to content

Host environment path #590

Open
Open
@nickalbrecht

Description

@nickalbrecht

Describe the bug

Just found this and was trying out the resource integrity helper in a local dev environment, but was getting an error about the local file not being found.
I did some digging into the source but wasn't sure if this was a bug or if I'm using it wrong. Assuming the intent is to fallback to the local version of a resource if its hash doesn't match that of the CDN, shouldn't the logic in the GetSubresourceIntegrityFromContentFile() be combining the relative path with WebRootPath, not ContentRootPath?

Steps to reproduce

I was trying this with jQuery as a test and was using the below tag

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.4/jquery.min.js"
        asp-subresource-integrity-src="~/js/jquery/jquery.min.js"
        asp-fallback-src="~/js/jquery/jquery.min.js" asp-append-version="true"
        asp-fallback-test="window.jQuery"></script>

Expected behaviour

Was expecting it to output the script tag with a SRI hash

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssues describing a bug or pull requests fixing a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions