Permalink
Browse files

Added a helper function to parse a webfinger acct uri.

  • Loading branch information...
1 parent fcfe4e2 commit b9c51354b5782831d52f935ae712dd90486b406a @eschnou committed Feb 10, 2011
Showing with 21 additions and 1 deletion.
  1. +21 −1 lib/ostatus/webfinger.js
@@ -75,6 +75,25 @@ function lookup(identifier, callback) {
});
}
+function parseAcct(pAcct) {
+ // Add the acct prefix if required
+ if (pAcct<5 || pAcct.substring(0,5) != "acct:") {
+ pAcct = "acct:" + pAcct;
+ }
+
+ // Validate the user account
+ var acct = Url.parse(pAcct);
+ if (acct == undefined || acct.auth == undefined || acct.hostname == undefined) {
+ return false;
+ }
+
+ // Return the parsed account
+ var result = {};
+ result.hostname = acct.hostname;
+ result.username = acct.auth;
+ return result;
+}
+
function _fetchHostMeta(host, callback) {
var url = "http://" + host + "/.well-known/host-meta";
console.log("Requesting host meta at " + url);
@@ -107,4 +126,5 @@ function _fetchUserMeta(template, identifier, callback) {
exports.lookup = lookup;
exports.xrd = xrd;
-exports.lrdd = lrdd;
+exports.lrdd = lrdd;
+exports.parseAcct = parseAcct;

0 comments on commit b9c5135

Please sign in to comment.