Filter by slug from URL (advanced) Channel: Restaurants

Channel: Nutrition / contains entries field named restaurant. 

Required URL format:
    restaurant-name-nutrition

since the URL structure is merged I can't use getSegement(x) while getting entries.

in other scenario where the URL would be

nutrition/restaurant-name

I could use something like this

{% set seg2 = craft.request.getSegment(2)
{% for entry in craft.entries.section('nutrition').slug(seg2) %}


but what is the right approach for that one?
Why don't you use your current entry as reference?

{% set nutritions = craft.entries.section('nutrition').relatedTo({
    field: 'restaurant',
    targetElement: entry
}).all() %}


Since your current entry is related to the entry you want to fetch this would be the besser solution. However that URL structure is not really optimal to beginn with. There are many cases it will break as soon as someone edits your entries, but filtering by slug alone is never a good idea in such a way.