How do you add a class based on URL in twig?

I am creating a site for a customer that has two exhibits within the site. They want the exhibits to retain the styling of the rest of the site but they would like the sidebar to have a different color within those exhibits.

I created a javascript line that changed the color of the sidebar based on the URL and it seems to be working fine. My manager however would rather I accomplish this in Twig instead.

Is there a way that I can create an “if” statement that determines a class based what is included in the URL? For example If ‘exhibit’ is included in the url (www.mysite.com/exhibit/example) then add a class etc?

I apologize in advance, I am not great at asking questions. Thanks