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.

functions.any.js 995B

1234567891011121314151617181920212223242526272829303132
  1. // @flow
  2. import { getAppProp } from '../base/app';
  3. import { toState } from '../base/redux';
  4. import { getServerURL } from '../base/settings';
  5. /**
  6. * Retrieves the default URL for the app. This can either come from a prop to
  7. * the root App component or be configured in the settings.
  8. *
  9. * @param {Function|Object} stateful - The redux store or {@code getState}
  10. * function.
  11. * @returns {string} - Default URL for the app.
  12. */
  13. export function getDefaultURL(stateful: Function | Object) {
  14. const state = toState(stateful);
  15. const { app } = state['features/base/app'];
  16. // If the execution environment provides a Location abstraction (e.g. a Web
  17. // browser), then we'll presume it's the one and only base URL it can be on.
  18. const windowLocation = app.getWindowLocation();
  19. if (windowLocation) {
  20. const href = windowLocation.toString();
  21. if (href) {
  22. return href;
  23. }
  24. }
  25. return getAppProp(state, 'defaultURL') || getServerURL(state);
  26. }