Couple of methods to get route name by using path

To get route name that you maybe want to use in some custom code you can get it with this 2 ways

$url = 'admin/commerce/config/shipping-methods';

$object =\Drupal::service('path.validator')->getUrlIfValid($url);


and you will have and URL object with info you can utilize. Other way is similar and output is an array

$url = 'admin/commerce/config/shipping-methods';

$request = \Symfony\Component\HttpFoundation\Request::create($url);
$router = \Drupal::service('router.no_access_checks');
$match = $router->matchRequest($request);