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

Loading relative dependencies with HTTP requests broken on 1.9.7 #152

Open
allyen opened this issue Sep 26, 2018 · 4 comments
Open

Loading relative dependencies with HTTP requests broken on 1.9.7 #152

allyen opened this issue Sep 26, 2018 · 4 comments

Comments

@allyen
Copy link
Contributor

allyen commented Sep 26, 2018

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 the uri.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.

@allyen
Copy link
Contributor Author

allyen commented Sep 26, 2018

It seems that other code parts called in this place are ok with relative paths -- the IsLocalUri extension method is prepared for local URIs...

@Shazwazza
Copy link
Owner

There's another discussion about a similar thing here: #147 (comment)

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?

@allyen
Copy link
Contributor Author

allyen commented Sep 27, 2018

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?

@Shazwazza
Copy link
Owner

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.

allyen pushed a commit to WebCentrum/ClientDependency that referenced this issue Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants