mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2026-01-18 00:44:25 +00:00
fix(staticweb): add nil check to WithStripPrefix helper
Prevent panic when WithStripPrefix is called with a nil provider.
This commit is contained in:
@@ -51,8 +51,10 @@ type PrefixStrippingProvider interface {
|
|||||||
// WithStripPrefix is a helper function that sets the strip prefix on a provider
|
// WithStripPrefix is a helper function that sets the strip prefix on a provider
|
||||||
// if it implements PrefixStrippingProvider. Returns the provider for method chaining.
|
// if it implements PrefixStrippingProvider. Returns the provider for method chaining.
|
||||||
func WithStripPrefix(provider FileSystemProvider, prefix string) FileSystemProvider {
|
func WithStripPrefix(provider FileSystemProvider, prefix string) FileSystemProvider {
|
||||||
if p, ok := provider.(PrefixStrippingProvider); ok {
|
if provider != nil {
|
||||||
p.WithStripPrefix(prefix)
|
if p, ok := provider.(PrefixStrippingProvider); ok {
|
||||||
|
p.WithStripPrefix(prefix)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return provider
|
return provider
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user