IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
808B

  1. //
  2. // Copyright (C) Stanislaw Adaszewski, 2020
  3. // Contact: s.adaszewski@gmail.com
  4. // Website: https://adared.ch/wba
  5. // License: GNU Affero General Public License, Version 3
  6. //
  7. function wbUuidsToCwl(obj) {
  8. if (obj instanceof Array) {
  9. const res = [];
  10. for (let k in obj) {
  11. res[k] = wbUuidsToCwl(obj[k]);
  12. }
  13. return res;
  14. }
  15. if (typeof(obj) === 'string' &&
  16. (/^[0-9a-z]{5}-[0-9a-z]{5}-[0-9a-z]{15}/.exec(obj) ||
  17. /^[0-9a-f]{32}\+[0-9]+/.exec(obj))) {
  18. const isDirectory = obj.endsWith('/');
  19. return {
  20. 'class': (isDirectory ? 'Directory' : 'File'),
  21. 'location': 'keep:' + (isDirectory ? obj.substr(0, obj.length - 1) : obj)
  22. };
  23. }
  24. throw Error('Expected Arvados path or array of paths');
  25. }
  26. export default wbUuidsToCwl;