logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

link_header.js (791B)


  1. import Link from 'http-link-header';
  2. import querystring from 'querystring';
  3. Link.parseAttrs = (link, parts) => {
  4. let match = null;
  5. let attr = '';
  6. let value = '';
  7. let attrs = '';
  8. let uriAttrs = /<(.*)>;\s*(.*)/gi.exec(parts);
  9. if(uriAttrs) {
  10. attrs = uriAttrs[2];
  11. link = Link.parseParams(link, uriAttrs[1]);
  12. }
  13. while(match = Link.attrPattern.exec(attrs)) { // eslint-disable-line no-cond-assign
  14. attr = match[1].toLowerCase();
  15. value = match[4] || match[3] || match[2];
  16. if( /\*$/.test(attr)) {
  17. Link.setAttr(link, attr, Link.parseExtendedValue(value));
  18. } else if(/%/.test(value)) {
  19. Link.setAttr(link, attr, querystring.decode(value));
  20. } else {
  21. Link.setAttr(link, attr, value);
  22. }
  23. }
  24. return link;
  25. };
  26. export default Link;