```ruby
sub!(%r{^/*}, '').sub!(%r{/*$}, '')
```

Is used multiple times. Is there any chance to encapsulate this?