Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.

parseProxyUrl.js.flow 874B

123456789101112131415161718192021222324252627282930313233343536
  1. // @flow
  2. import {
  3. parse as parseUrl,
  4. } from 'url';
  5. import {
  6. UnexpectedStateError,
  7. } from '../errors';
  8. export default (url: string) => {
  9. const urlTokens = parseUrl(url);
  10. if (urlTokens.query !== null) {
  11. throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL must not have query.');
  12. }
  13. if (urlTokens.hash !== null) {
  14. throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL must not have hash.');
  15. }
  16. if (urlTokens.protocol !== 'http:') {
  17. throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL protocol must be "http:".');
  18. }
  19. let port = 80;
  20. if (urlTokens.port) {
  21. port = Number.parseInt(urlTokens.port, 10);
  22. }
  23. return {
  24. authorization: urlTokens.auth || null,
  25. hostname: urlTokens.hostname,
  26. port,
  27. };
  28. };