Skip to content
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

feat(root):生成scheme时候增加fragment #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions dist/index.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,9 @@
*/
function buildScheme(config, options) {
var path = config.path,
param = config.param;
param = config.param,
_config$fragment = config.fragment,
fragment = _config$fragment === undefined ? '' : _config$fragment;
var customBuildScheme = options.buildScheme;


Expand All @@ -543,8 +545,9 @@
return key + '=' + param[key];
}).join('&') : '';
var urlQuery = query ? '?' + query : '';
var urlFragment = fragment && fragment[0] !== '#' ? '#' + fragment : fragment;

return protocol + '://' + hostPort + path + urlQuery;
return protocol + '://' + hostPort + path + urlQuery + urlFragment;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion dist/index.umd.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions sources/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @memberof CallApp
*/
export function buildScheme(config, options) {
const { path, param } = config;
const { path, param, fragment = '' } = config;
const { buildScheme: customBuildScheme } = options;

if (typeof customBuildScheme !== 'undefined') {
Expand All @@ -19,8 +19,9 @@ export function buildScheme(config, options) {
const hostPort = host ? `${host}${portPart}/` : '';
const query = typeof param !== 'undefined' ? Object.keys(param).map(key => `${key}=${param[key]}`).join('&') : '';
const urlQuery = query ? `?${query}` : '';
const urlFragment = fragment && fragment[0] !== '#' ? '#' + fragment : fragment;

return `${protocol}://${hostPort}${path}${urlQuery}`;
return `${protocol}://${hostPort}${path}${urlQuery}${urlFragment}`;
}

/**
Expand Down