Skip to content

Commit d3aabba

Browse files
committed
Add the ability to parse a URL to determine namespace and federation
1 parent f87de96 commit d3aabba

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Client.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@ export class Client {
146146
.map(scope => scope.split(':')[0] as TokenPermission)
147147
}
148148

149+
/**
150+
* Parse an object URL for its federation and namespace
151+
*/
152+
async parseObjectUrl(objectUrl: string) : Promise<{federation: string, namespace: string}> {
153+
const { federationHostname } = parsePelicanObjectUrl(objectUrl)
154+
const federation = await this.getFederation(federationHostname)
155+
const namespace = await this.getNamespace(objectUrl, federation)
156+
return {federation: federation.hostname, namespace: namespace.prefix}
157+
}
158+
149159
/**
150160
* If there is an authorization code in the URL, exchange it for a token and save it to the appropriate namespace
151161
*/

0 commit comments

Comments
 (0)