webjars / webjars-locator-core

Webjars-locator core functionality
MIT License
19 stars 32 forks source link

Is there a way to exclude paths from the searching? #17

Open wimdeblauwe opened 7 years ago

wimdeblauwe commented 7 years ago

I want to use bootstrap-select (https://silviomoreto.github.io/bootstrap-select/) with Webjars. However, I get a MultipleMatchesFoundException. Which is normal given the structure of the webjar:

image

Is there any setting I can do to avoid that anything under docs gets matched?

jamesward commented 7 years ago

Can you try to use getFullPathExact: https://javadoccentral.herokuapp.com/org.webjars/webjars-locator-core/0.32/org/webjars/WebJarAssetLocator.html#getFullPathExact-java.lang.String-java.lang.String-

Like: webJarAssetLocator.getFullPathExact("bootstrap-select", "dist/css/bootstrap-select.min.css")

Let me know if that works.

wimdeblauwe commented 7 years ago

I am using Spring Boot 1.5.x with webjars-locator which does all the magic. Any way I can influence this magic?

jamesward commented 7 years ago

Hmmm... I'm not sure. Maybe @royclarkson can help.

royclarkson commented 7 years ago

Appears there is a fix for the MultipleMatchesFoundException in Spring Framework. https://github.com/spring-projects/spring-framework/pull/1420

maybeec commented 7 years ago

The current implementation even fails for jars, which declare a packed file equally named as one of the source files. I just made a test with moment.js, which serves multiple moment.js files:

[
META-INF/resources/webjars/moment/2.18.1/src/lib/moment/moment.js, 
META-INF/resources/webjars/moment/2.18.1/src/moment.js, 
META-INF/resources/webjars/moment/2.18.1/moment.js
]

However, the first entry in the sorted list already gives you the correct pointer (last element of the list).

jamesward commented 7 years ago

Does Spring somehow expose the getFullPathExact method? That is the right way to do this, like:

locator.getFullPathExact("moment", "moment.js")
maybeec commented 7 years ago

The first parameter is the webjar name. So this API would end up in three matches as well for the example above.

jamesward commented 7 years ago

The getFullPathExact doesn't do partial matching. It really just inserts the version between the WebJar name and the provided path.