Yeah, as discussed this is just splitting into hostname (unqualified) and domain name, if present, eg:

"foo-app-01.example.com" => ["foo-app-01", "example.com"]
"foo-app-01" => ["foo-app-01"]