Skip to content

RegexAdjustRelativePaths does not take account of cache file being stored on different url (i.e. blob storage) #10

@I3undy

Description

@I3undy

rdobson created on Sep 3, 2014:
https://combinator.codeplex.com/workitem/66

I have changed to the following:

private static void RegexAdjustRelativePaths(CombinatorResource resource, Uri cacheFileUri)
{
    RegexProcessUrls(resource,
        (match) =>
        {
            var url = match.Groups[1].ToString();

            var uri = RegexMakeInlineUri(resource, url);

            // Remote paths are preserved as full urls, local paths become uniformed relative ones.
            var uriString = "";
            if (resource.IsCdnResource || resource.AbsoluteUrl.Host != uri.Host || resource.AbsoluteUrl.Port != uri.Port)
                uriString = uri.ToProtocolRelative();
            else if (cacheFileUri != null && (cacheFileUri.Host != uri.Host || cacheFileUri.Port != uri.Port))
                uriString = uri.ToProtocolRelative();
            else
                uriString = uri.PathAndQuery;

            return "url(\"" + uriString + "\")";
        });
}

I am passing in a uri of a fake file in storage to check against using the following method in CacheFileService:

public Uri GetUri() {
        try {
            var publicUrl = _storageProvider.GetPublicUrl("test.txt");
            return new Uri(publicUrl);
        }
// ReSharper disable once EmptyGeneralCatchClause
        catch {
        }
        return null;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions