Skip to content
Browse files

let's try with xml2js v0.1.14

  • Loading branch information...
1 parent 5df4d98 commit 155d727ab8b32806d24b37c99d57c1b417ee05e2 @michielbdejong committed
Showing with 32 additions and 31 deletions.
  1. +2 −2 package.json
  2. +28 −29 parser/xrd.js
  3. +2 −0 unitTests.js
View
4 package.json
@@ -8,13 +8,13 @@
"scripts": {
"start": "server.js"
},
- "version": "0.0.0-61",
+ "version": "0.0.0-62",
"engines": {
"node": "0.6.x"
},
"dependencies": {
"sockjs": "*",
- "xml2js": "0.1.8",
+ "xml2js": "0.1.14",
"htmlparser": "*"
}
}
View
57 parser/xrd.js
@@ -28,39 +28,38 @@ exports.parse = function(url, docRel, headers, content, cb) {
data2.Property = [data2.Property];
}
}
- if(data2.XRD) {
- data2=data2.XRD;
- }
+ //if(data2.XRD) {
+ // data2=data2.XRD;
+ //}
if(!data2.Link) {
console.log('no .Link:');
console.log(data2);
- } else {
- if(data2.Link['@']) {
- data2.Link = [data2.Link];
- }
- for(var i=0; i<data2.Link.length; i++) {
- if(data2.Link[i]['@'] && data2.Link[i]['@'].rel == 'http://webfinger.net/rel/avatar') {
- obj.images.avatar = data2.Link[i]['@'].href;
- } else if(data2.Link[i]['@'] && data2.Link[i]['@'].rel == 'describedby' && data2.Link[i]['@'].type == 'application/rdf+xml') {
- obj.documents[data2.Link[i]['@'].href] = 'describedby';
- } else if(data2.Link[i]['@'] && data2.Link[i]['@'].rel == 'http://portablecontacts.net/spec/1.0') {
- if(data2.Link[i]['@'].href != 'http://www-opensocial.googleusercontent.com/api/people/') {//bug in that specific node
- obj.documents[data2.Link[i]['@'].href] = 'poco';
- }
- } else if(data2.Link[i]['@'] && data2.Link[i]['@'].rel == 'http://microformats.org/profile/hcard') {
- obj.documents[data2.Link[i]['@'].href] = 'hcard';
- } else if(data2.Link[i]['@'] && data2.Link[i]['@'].rel == 'http://portablecontacts.net/spec/1.0#me') {
- obj.documents[data2.Link[i]['@'].href] = 'poco-me';
- } else if(data2.Link[i]['@'] && data2.Link[i]['@'].rel == 'lrdd') {
- var templateParts = data2.Link[i]['@'].template.split('{uri}');
- if(url.indexOf('/.well-known/host-meta?resource=acct:')) {
- obj.documents[templateParts[0]+url.substring(url.indexOf('/.well-known/host-meta?resource=acct:')+'/.well-known/host-meta?resource='.length)+templateParts[1]] = 'lrdd';
- }
- } else if(data2.Link[i]['@'] && data2.Link[i]['@'].rel == 'http://webfinger.net/rel/profile-page') {
- obj.tools[data2.Link[i]['@'].href] = 'R';
- } else if(data2.Link[i]['@'] && data2.Link[i]['@'].rel == 'http://schemas.google.com/g/2010#updates-from') {
- obj.tools[data2.Link[i]['@'].href] = 'S';
+ }
+ if(data2.Link['@']) {
+ data2.Link = [data2.Link];
+ }
+ for(var i=0; i<data2.Link.length; i++) {
+ if(data2.Link[i]['@'] && data2.Link[i]['@'].rel == 'http://webfinger.net/rel/avatar') {
+ obj.images.avatar = data2.Link[i]['@'].href;
+ } else if(data2.Link[i]['@'] && data2.Link[i]['@'].rel == 'describedby' && data2.Link[i]['@'].type == 'application/rdf+xml') {
+ obj.documents[data2.Link[i]['@'].href] = 'describedby';
+ } else if(data2.Link[i]['@'] && data2.Link[i]['@'].rel == 'http://portablecontacts.net/spec/1.0') {
+ if(data2.Link[i]['@'].href != 'http://www-opensocial.googleusercontent.com/api/people/') {//bug in that specific node
+ obj.documents[data2.Link[i]['@'].href] = 'poco';
+ }
+ } else if(data2.Link[i]['@'] && data2.Link[i]['@'].rel == 'http://microformats.org/profile/hcard') {
+ obj.documents[data2.Link[i]['@'].href] = 'hcard';
+ } else if(data2.Link[i]['@'] && data2.Link[i]['@'].rel == 'http://portablecontacts.net/spec/1.0#me') {
+ obj.documents[data2.Link[i]['@'].href] = 'poco-me';
+ } else if(data2.Link[i]['@'] && data2.Link[i]['@'].rel == 'lrdd') {
+ var templateParts = data2.Link[i]['@'].template.split('{uri}');
+ if(url.indexOf('/.well-known/host-meta?resource=acct:')) {
+ obj.documents[templateParts[0]+url.substring(url.indexOf('/.well-known/host-meta?resource=acct:')+'/.well-known/host-meta?resource='.length)+templateParts[1]] = 'lrdd';
}
+ } else if(data2.Link[i]['@'] && data2.Link[i]['@'].rel == 'http://webfinger.net/rel/profile-page') {
+ obj.tools[data2.Link[i]['@'].href] = 'R';
+ } else if(data2.Link[i]['@'] && data2.Link[i]['@'].rel == 'http://schemas.google.com/g/2010#updates-from') {
+ obj.tools[data2.Link[i]['@'].href] = 'S';
}
}
cb(null, obj);
View
2 unitTests.js
@@ -36,6 +36,7 @@ function doFile(url, expect) {
});
}
masterParser.setEnv('test');
+/*
doFile('michielbdejong@identi.ca', {
textFields:
{ fullName: 'Michiel de Jong',
@@ -195,6 +196,7 @@ doFile('http://www.w3.org/People/Berners-Lee/card.rdf', {
'https://facebook.com/tim.bernerslee.9': 'R',
'facebook:tim.bernerslee.9': 'RSCM' }
});
+*/
doFile('michiel@nlnet.nl', {
textFields: {
type: 'user',

0 comments on commit 155d727

Please sign in to comment.
Something went wrong with that request. Please try again.