Skip to content

Commit

Permalink
fix: hhttp:baseUrl和url 拼接时,多余斜杠处理
Browse files Browse the repository at this point in the history
Hhttp:baseUrl和url 拼接时,多余斜杠处理
  • Loading branch information
hewx815 committed Jun 7, 2023
1 parent 2ba94cc commit b02dade
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 24 deletions.
10 changes: 1 addition & 9 deletions cli/storage/index.json
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
{
"USER_LAST_MODE": {
"updataTime": "Fri Apr 28 2023 20:42:12 GMT+0800 (中国标准时间)",
"data": {
"devFolder": "for-vue2",
"script": "dev:h5"
}
}
}
{"USER_LAST_MODE":{"updataTime":"Mon Jun 05 2023 16:56:43 GMT+0800 (中国标准时间)","data":{"devFolder":"for-vue2","script":"dev:app-plus"}}}
6 changes: 5 additions & 1 deletion for-vue2/src/packages/utils/Hhttp/Hhttp.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ export default class Hhttp {
}

// 请求配置策略
static getUrl = (baseUrl, url = '') => baseUrl + url;
static getUrl = (baseUrl, url = '') => {
const base = baseUrl.replace(/\/+$/, ''); // 去掉baseUrl末尾的斜杠
const path = url.replace(/^\/+/, ''); // 去掉url开头的斜杠
return `${base}/${path}`;
};

static getHeader = (baseHeader, header = {}) => ({ ...baseHeader, ...header });

Expand Down
15 changes: 1 addition & 14 deletions for-vue2/src/pages.json
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
{
"pages": [
{
"path": "test/indexPage",
"style": { "navigationBarTitleText": "uni-app" }
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#999",
"backgroundColor": "#F8F8F8"
}
}
{"pages":[{"path":"test/indexPage","style":{"navigationBarTitleText":"uni-app"}}],"globalStyle":{"navigationBarTextStyle":"black","navigationBarTitleText":"uni-app","navigationBarBackgroundColor":"#999","backgroundColor":"#F8F8F8"}}

0 comments on commit b02dade

Please sign in to comment.