本文整理汇总了TypeScript中wherehows-web/utils/build-url.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: buildUrl
export const datasetsUrl = ({ platform, prefix, start = 0 }: IReadDatasetsOptionBag): string => {
const urlRoot = datasetsUrlRoot('v2');
let url = urlRoot;
if (platform) {
url = `${urlRoot}/platform/${platform}`;
if (prefix) {
url = `${urlRoot}/platform/${platform}/prefix/${encodeForwardSlash(prefix)}`;
}
}
return buildUrl(url, 'start', `${start}`);
};
示例2: buildUrl
export const searchUrl = ({ facets, ...params }: ISearchApiParams): string => {
return buildUrl(`${getApiRoot()}/search`, { ...params, ...fromRestli(facets || '') });
};
示例3: buildUrl
export const suggestionsUrl = (params: ISuggestionsApi): string => {
return buildUrl(`${getApiRoot()}/autocomplete/datasets`, params);
};
示例4: test
test('baseUrl', function(assert) {
let result = buildUrl(baseUrl);
assert.equal(result, baseUrl, 'it returns the base url when no other arguments are passed');
result = buildUrl(baseUrl, {});
assert.equal(result, baseUrl, 'it returns the base url when an empty object is supplied as query parameter');
result = buildUrl(baseUrl, '');
assert.equal(result, baseUrl, 'it returns the base url when an empty string is supplied as query parameter');
result = buildUrl(baseUrl, '', true);
assert.equal(
result,
baseUrl,
'it returns the base url when the queryParam is an empty string and the useEncoding is set'
);
result = buildUrl(baseUrl, 'query', true);
assert.equal(
result,
`${baseUrl}?query=true`,
'it returns the base url with a query key set to true when true is passed as a query value'
);
result = buildUrl(baseUrl, 'query', unEncodedString, true);
assert.equal(
result,
`${baseUrl}?query=${encodedString}`,
'it returns the encoded value when the useEncoding flag is true'
);
result = buildUrl(baseUrl, { query: unEncodedString }, true);
assert.equal(result, `${baseUrl}?query=${encodedString}`, 'it returns the encoded string on a queryParams object');
result = buildUrl(baseUrl, '', '');
assert.equal(result, baseUrl, 'returns the baseUrl when no query parameter is supplied');
result = buildUrl(baseUrl, 'search', 'text');
assert.equal(result, `${baseUrl}?search=text`);
result = buildUrl(result, 'query', 'text2');
assert.equal(result, `${baseUrl}?search=text&query=text2`);
result = buildUrl(baseUrl, {
keyName1: 'keyValue1',
keyName2: 2,
keyName3: true
});
assert.equal(result, `${baseUrl}?keyName1=keyValue1&keyName2=2&keyName3=true`);
result = buildUrl(baseUrl, {
keyName1: 0,
keyName3: undefined,
keyName4: '',
keyName5: null,
keyName2: false
});
assert.equal(result, `${baseUrl}?keyName1=0&keyName2=false`);
});
示例5: buildUrl
const buildMailToUrl = (headers: IMailHeaderRecord = {}): string => {
const { to = '', ...otherHeaders } = headers;
const mailTo = `mailto:${encodeURIComponent(to)}`;
return buildUrl(mailTo, otherHeaders);
};