How can Istio VirtualService match URIs?

How can Istio VirtualService match URIs?
For example, in the case of the BookInfo sample,
can service discovery be done through each service labels and selector?
I wonder how internally Istio detects deployed microservices.