您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

functions.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* @flow */
  2. /**
  3. * Retrieves a simplified version of the conference/location URL stripped of URL
  4. * params (i.e. query/search and hash) which should be used for sending invites.
  5. *
  6. * @param {Function|Object} stateOrGetState - The redux state or redux's
  7. * {@code getState} function.
  8. * @returns {string|undefined}
  9. */
  10. export function getInviteURL(stateOrGetState: Function | Object): ?string {
  11. const state
  12. = typeof stateOrGetState === 'function'
  13. ? stateOrGetState()
  14. : stateOrGetState;
  15. const { locationURL } = state['features/base/connection'];
  16. let inviteURL;
  17. if (locationURL) {
  18. inviteURL = getURLWithoutParams(locationURL).href;
  19. }
  20. return inviteURL;
  21. }
  22. /**
  23. * Gets a {@link URL} without hash and query/search params from a specific
  24. * {@code URL}.
  25. *
  26. * @param {URL} url - The {@code URL} which may have hash and query/search
  27. * params.
  28. * @returns {URL}
  29. */
  30. export function getURLWithoutParams(url: URL): URL {
  31. const { hash, search } = url;
  32. if ((hash && hash.length > 1) || (search && search.length > 1)) {
  33. // eslint-disable-next-line no-param-reassign
  34. url = new URL(url.href);
  35. url.hash = '';
  36. url.search = '';
  37. }
  38. return url;
  39. }