I guess this is as best of a start as you can get. It now deals with: .co.uk or whatever multi-part domain types, protocol, www-less, protocol-less etc. I plan to make it a library plugin.
https://github.com/WebSudosUK/framework/blob/master/com.websudos.urlMatcher.js