1
0
Fork 0

Add debug assertion for custom feature namespaces

This commit is contained in:
Robbert van der Helm 2022-11-22 21:19:17 +01:00
parent 7c732e594c
commit d9284ef0b7

View file

@ -85,7 +85,19 @@ impl ClapFeature {
ClapFeature::Stereo => "stereo", ClapFeature::Stereo => "stereo",
ClapFeature::Surround => "surround", ClapFeature::Surround => "surround",
ClapFeature::Ambisonic => "ambisonic", ClapFeature::Ambisonic => "ambisonic",
ClapFeature::Custom(s) => s, ClapFeature::Custom(s) => {
// Custom features must be prefixed with a namespace. We'll use `.split(':').all()`
// here instead of `.split_once()` in case the user for whatever reason uses more
// than one colon (which the docs don't say anything about, but uh yeah).
nih_debug_assert!(
s.contains(':') && s.split(':').all(|x| !x.is_empty()),
"'{s}' is not a valid feature, custom features must be namespaced (e.g. \
'nih:{s}')",
s = s
);
s
}
} }
} }
} }