Commit 97cd4024 authored by Fabien Amarger's avatar Fabien Amarger

feat(prefix): Get prefixed URI from prefix.cc

parent 48693cb4a0f1
Pipeline #50853 passed with stages
in 2 minutes and 31 seconds
......@@ -19,3 +19,4 @@ export interface ViewDescription {
}
export {ViewWrapper} from './ViewWrapper';
export {prefixedNameFromUri} from './prefix';
export async function prefixedNameFromUri(uri: string): Promise<string> {
const resp = await fetch(
`http://prefix.cc/reverse?uri=${encodeURIComponent(uri)}`
);
let prefixedUri = uri;
if (resp.statusText === 'OK') {
// remove "http://prefix.cc/" from the url to get the prefixed URI
prefixedUri = resp.url.substring(resp.url.lastIndexOf('/') + 1);
}
return prefixedUri;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment