Open allyen opened 6 years ago
It seems that other code parts called in this place are ok with relative paths -- the IsLocalUri
extension method is prepared for local URIs...
There's another discussion about a similar thing here: https://github.com/Shazwazza/ClientDependency/issues/147#issuecomment-423111708
By the time it reaches that line of code that you mention, the path must be an absolute URI. For relative paths, the CanProcessLocally
method should return a boolean. What is an example of the path that isn't passing the CanProcessLocally check that isn't an absolute URL?
I see. The problem is that the extension of our custom generated JS files is included in config in @fileDependencyExtensions
but it doesn't have an IVirtualFileWriter
registered. Instead, these files are processed by a surface controller which requires the WritePathToStream
method to call an URL which it now won't do for a relative path. So the correct approach would by to write a custom IVirtualFileWriter
?
That will be one way to make it work for sure. If you want to create a PR to allow for non-absolute paths for that specific line i can run some tests to see if it can be allowed.
With the 1.9.7 upgrade it stopped to be possible to load local relative URIs over HTTP requests. We use this for generating JS code via razor (something like this) -- sometimes useful, although the generated JS must be immutable to make it's caching meaningful :). We could resolve it by putting absolute URIs into the
RequiresJs
calls but this doesn't feel quite right since with static assets it works.As for the origin of this issue -- at https://github.com/Shazwazza/ClientDependency/blob/master/ClientDependency.Core/CompositeFiles/Providers/BaseCompositeFileProcessingProvider.cs#L217 there's a call to
uri.PathAndQuery
which throws for relative URIs. Would it make sense to elaborate on theuri.PathAndQuery
part (make it a variable and add some if's) to enable passing local paths? If yes, I can come up with a pull request.