improved router to allow placeholders anywhere in a pattern to become optional