utils.ts 711 B

123456789101112131415161718192021222324252627
  1. /**
  2. * 请求工具所使用的工具函数
  3. *
  4. * 功能介绍:
  5. * 提供了一些处理工具函数,方便使用。
  6. *
  7. * Author: imengyu
  8. * Date: 2022/03/25
  9. *
  10. * Copyright (c) 2021 imengyu.top. Licensed under the MIT License.
  11. * See License.txt in the project root for license information.
  12. */
  13. /* eslint-disable no-bitwise */
  14. /**
  15. * 移除URL的地址部分,只保留路径
  16. * @param str 原URL
  17. * @returns
  18. */
  19. export function removeUrlOrigin(str: string) : string {
  20. if(str.startsWith('http://') || str.startsWith('https://') || str.startsWith('fts://') || str.startsWith('ftps://')) {
  21. str = str.substr(str.indexOf('://') + 3);
  22. str = str.substr(str.indexOf('/') + 1);
  23. }
  24. return str;
  25. }