I don't think you can hard-code checking for 5 components in the path - as widgets may contain content in sub-folders, e.g. /widget/<install_id>/<session_id>/folder1/folder2/index.html

It's probably sufficient that the path has /widget/<install_id>/<session_id> components.