authority.js 316 Bytes
Newer Older
邓晓峰's avatar
邓晓峰 committed
1
export function getAuthority(str) {
2
  const authorityString = str;
邓晓峰's avatar
邓晓峰 committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

  let authority;
  try {
    if (authorityString) {
      authority = JSON.parse(authorityString);
    }
  } catch (e) {
    authority = authorityString;
  }
  if (typeof authority === 'string') {
    return [authority];
  }

  return authority;
}