当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript build-url.default函数代码示例

本文整理汇总了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}`);
};
开发者ID:alyiwang,项目名称:WhereHows,代码行数:14,代码来源:shared.ts

示例2: buildUrl

export const searchUrl = ({ facets, ...params }: ISearchApiParams): string => {
  return buildUrl(`${getApiRoot()}/search`, { ...params, ...fromRestli(facets || '') });
};
开发者ID:alyiwang,项目名称:WhereHows,代码行数:3,代码来源:search.ts

示例3: buildUrl

export const suggestionsUrl = (params: ISuggestionsApi): string => {
  return buildUrl(`${getApiRoot()}/autocomplete/datasets`, params);
};
开发者ID:alyiwang,项目名称:WhereHows,代码行数:3,代码来源:suggestions.ts

示例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`);
  });
开发者ID:alyiwang,项目名称:WhereHows,代码行数:59,代码来源:build-url-test.ts

示例5: buildUrl

const buildMailToUrl = (headers: IMailHeaderRecord = {}): string => {
  const { to = '', ...otherHeaders } = headers;
  const mailTo = `mailto:${encodeURIComponent(to)}`;

  return buildUrl(mailTo, otherHeaders);
};
开发者ID:alyiwang,项目名称:WhereHows,代码行数:6,代码来源:email.ts


注:本文中的wherehows-web/utils/build-url.default函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。