Skip to content

modify method when pass absolute path for option.base #1353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions dist/vue-router.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,9 @@ function parsePath (path) {
}

function cleanPath (path) {
return path.replace(/\/\//g, '/')
var ishttp = /^\w+:\/\//.exec(path);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RepExpr here needs to be modified. because there's still this kind of situation:

//google.com

so the RegExpr should be it

/^([a-z]+:)?\/\//i

var http = Array.isArray(ishttp) ? ishttp[0] : '';
return http + path.substr(http.length).replace(/\/{2,}/g, '/');
}

/* */
Expand Down Expand Up @@ -1759,7 +1761,9 @@ function normalizeBase (base) {
}
}
// make sure there's the starting slash
if (base.charAt(0) !== '/') {
if(/^[a-z]+:\/\//i.test(base)){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RepExpr here needs to be modified. because there's still this kind of situation:

//google.com
so the RegExpr should be it

/^([a-z]+:)?///i


}else if (base.charAt(0) !== '/') {
base = '/' + base;
}
// remove trailing slash
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请问,需要修改源码才能实现在History模式下去掉http://api.com/http:/static.com/test前面的部分吗

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一般/开头的都是站内link , 如果是站外 link 的话, 可以使用<a target="_blank"></a>

Expand Down