diff --git a/swh/loader/npm/tests/test_utils.py b/swh/loader/npm/tests/test_utils.py --- a/swh/loader/npm/tests/test_utils.py +++ b/swh/loader/npm/tests/test_utils.py @@ -266,3 +266,28 @@ 'email': None } ) + + package_json = json.loads(''' + { + "name": "yfe-ynpm", + "version": "1.0.0", + "homepage": "http://gitlab.ywwl.com/yfe/yfe-ynpm", + "repository": { + "type": "git", + "url": "git@gitlab.ywwl.com:yfe/yfe-ynpm.git" + }, + "author": [ + "fengmk2 (https://fengmk2.com)", + "xufuzi (https://7993.org)" + ], + "license": "MIT" + }''') + + self.assertEqual( + extract_npm_package_author(package_json), + { + 'fullname': b'fengmk2 ', + 'name': b'fengmk2', + 'email': b'fengmk2@gmail.com' + } + ) diff --git a/swh/loader/npm/utils.py b/swh/loader/npm/utils.py --- a/swh/loader/npm/utils.py +++ b/swh/loader/npm/utils.py @@ -86,6 +86,8 @@ if 'email' in author_data: author_str += ' <%s>' % author_data['email'] return author_str + elif type(author_data) is list: + return author_data[0] if len(author_data) > 0 else '' else: return author_data