Beware of the language.
$language = preg_replace('/^\/([^\/]*)\/.*/', '${1}', $newsrc);
$newsrc = preg_replace('/^\/[^\/]*(\/.*)/', '${1}', $newsrc);
$path = \Drupal::service('path_alias.manager')->getPathByAlias($newsrc, $language);
$url = \Drupal\Core\Url::fromUserInput($path, ['language' => $language]);
$params = $url->getRouteParameters();
$entity_type_id = array_key_first($params);
especially if you're running the code inside a drush script.
$language should be the language of the target link and $src should be stripped from the language prefix.
If you just want to know if there is a valid internal page
$route_match = \Drupal::service('router.no_access_checks')->match($path);
if ($route_match !== \Drupal\Core\Routing::RouteMatchInterface::NO_ROUTE) {
// do something
}
This can be tricky to discover since it works without stripping the prefix AND without passing $language for English (or probably the default or fallback language).
There should be something buried in Symphony or Drupal code that does all this more elegantly but I haven't been able to discover it.
Somehow "normal" routing already does all this.