You shouldn't try to parse the URL. The localised namespace names across different projects are constantly changing and it is hard to get an up-to-date list. There are also cases where one localised name refer to two different namespaces on two projects.
You should be able to tell the namespace of a link by querying for its properties.
https://en.wikipedia.org/w/api.php?action=query&prop=info&format=json&titles=File%3AWiki.png
Look for the ns property.
{
"query": {
"pages": {
"28680696": {
"pageid": 28680696,
"ns": 6,
"title": "File:Wiki.png",
"contentmodel": "wikitext",
"pagelanguage": "en",
"touched": "2013-07-18T14:04:38Z",
"lastrevid": 560201242,
"counter": "",
"length": 786
}
}
}
}