I'm creating a text filter that modifies links. I am processing all the hrefs, and I want to load a RouteMatch or Url object for all valid urls like "/node/1". I need this to also handle i18n URLs. How do I convert a string like node/1 into a RouteMatch or Url object?
One way is to use the path validator service:
$url = \Drupal::service('path.validator')->getUrlIfValid($path)
I don't think that can handle URL's prefixed with the langcode if that's what you mean. That's usually handled/stored separately.
You may want to look at a question I asked a few months back.
Berdir had the suggestion to take the URI and first feed it to file_create_url(), which seems to clean up some of the URLs that may make Drupal 8 blow up.
This isn't 100%, since the change record he refers to has since landed. My sense is that URL code is a lot better than it was, but can still occasionally blow up, rather than just give an error.