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


TypeScript appUtils.formatUrl函数代码示例

本文整理汇总了TypeScript中@library/utility/appUtils.formatUrl函数的典型用法代码示例。如果您正苦于以下问题:TypeScript formatUrl函数的具体用法?TypeScript formatUrl怎么用?TypeScript formatUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了formatUrl函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: mountSwagger

export function mountSwagger() {
    SwaggerUIBundle({
        deepLinking: true,
        dom_id: "#swagger-ui",
        // layout: "DashboardLayout",
        plugins: [SwaggerUIBundle.plugins.DownloadUrl],
        presets: [SwaggerUIBundle.presets.apis],
        requestInterceptor: (request: Request) => {
            request.headers["x-transient-key"] = getMeta("TransientKey");
            return request;
        },
        url: formatUrl("/api/v2/open-api/v3" + window.location.search),
        validatorUrl: null,
    });
}
开发者ID:vanilla,项目名称:vanilla,代码行数:15,代码来源:mountSwagger.ts

示例2: it

    it("follows the given format", () => {
        application.setMeta("context.basePath", "/test");

        expect(application.formatUrl("/discussions")).eq("/test/discussions");
    });
开发者ID:vanilla,项目名称:vanilla,代码行数:5,代码来源:appUtils.test.ts

示例3: expect

 paths.forEach(path => {
     expect(application.formatUrl(path)).eq(path);
 });
开发者ID:vanilla,项目名称:vanilla,代码行数:3,代码来源:appUtils.test.ts

示例4: dispatch

 .then((response: AxiosResponse) => {
     dispatch(authenticatePasswordActions.success(response, params));
     const urlParms = new URLSearchParams();
     window.location.href = formatUrl(urlParms.get("target") || "/");
 })
开发者ID:vanilla,项目名称:vanilla,代码行数:5,代码来源:passwordActions.ts

示例5: callback

    const remoteDataHandler = (query, callback) => {
        // Do this because of undefined when adding spaces to
        // matcher callback, as it will be monitoring changes.
        query = query || "";

        // Only all query strings greater than min_characters
        if (query.length >= minCharacters) {
            // If the cache array contains less than LIMIT 30
            // (according to server logic), then there's no
            // point sending another request to server, as there
            // won't be any more results, as this is the maximum.
            let shouldContinueFiltering = true;

            // Remove last character so that the string can be
            // found in the cache, if exists, then check if its
            // matching array has less than the server limit of
            // matches, which means there are no more, so save the
            // additional server request from being sent.
            let filterString = "";

            // Loop through string and find first closest match in
            // the cache, and if a match, check if more filtering
            // is required.
            for (let i = 0, l = query.length; i < l; i++) {
                filterString = query.slice(0, -i);

                if (atCache[filterString] && atCache[filterString].length < serverLimit) {
                    // Add this other query to empty array, so that it
                    // will not fire off another request.
                    atEmpty[query] = query;

                    // Do not filter more, meaning, do not send
                    // another server request, as all the necessary
                    // data is already in memory.
                    shouldContinueFiltering = false;
                    break;
                }
            }

            // Check if query would be empty, based on previously
            // cached empty results. Compare against the start of
            // the latest query string.
            let isQueryEmpty = false;

            // Loop through cache of empty query strings.
            for (const key in atEmpty) {
                if (atEmpty.hasOwnProperty(key)) {
                    // See if cached empty results match the start
                    // of the latest query. If so, then no point
                    // sending new request, as it will return empty.
                    if (query.match(new RegExp("^" + key + "+")) !== null) {
                        isQueryEmpty = true;
                        break;
                    }
                }
            }

            const filterSuccessHandler = data => {
                if (Array.isArray(data)) {
                    data.forEach(result => {
                        if (typeof result === "object" && typeof result.name === "string") {
                            // Convert special characters to safely insert into template.
                            result.name = result.name
                                .replace(/&/g, "&amp;")
                                .replace(/</g, "&lt;")
                                .replace(/>/g, "&gt;")
                                .replace(/"/g, "&quot;")
                                .replace(/'/g, "&apos;");
                        }
                    });
                }

                callback(data);

                // If data is empty, cache the results to prevent
                // other requests against similarly-started
                // query strings.
                if (data.length) {
                    atCache[query] = data;
                } else {
                    atEmpty[query] = query;
                }
            };

            // Produce the suggestions based on data either
            // cached or retrieved.
            if (shouldContinueFiltering && !isQueryEmpty && !atCache[query]) {
                $.getJSON(
                    formatUrl("/user/tagsearch"),
                    {
                        q: query,
                        limit: serverLimit,
                    },
                    filterSuccessHandler,
                );
            } else {
                // If no point filtering more as the parent filter
                // has not been maxed out with responses, use the
                // closest parent filter instead of the latest
                // query string.
//.........这里部分代码省略.........
开发者ID:vanilla,项目名称:vanilla,代码行数:101,代码来源:atwho.ts

示例6: fieldErrorTransformer

import axios, { AxiosResponse, AxiosRequestConfig } from "axios";
import qs from "qs";
import { sprintf } from "sprintf-js";
import { humanFileSize } from "@library/utility/fileUtils";
import { IApiError, IFieldError } from "@library/@types/api/core";

function fieldErrorTransformer(responseData) {
    if (responseData && responseData.status >= 400 && responseData.errors && responseData.errors.length > 0) {
        responseData.errors = indexArrayByKey(responseData.errors, "field");
    }

    return responseData;
}

const apiv2 = axios.create({
    baseURL: formatUrl("/api/v2/"),
    headers: {
        common: {
            "X-Requested-With": "vanilla",
        },
    },
    transformResponse: [...(axios.defaults.transformResponse as any), fieldErrorTransformer],
    paramsSerializer: params => qs.stringify(params),
});

export default apiv2;

export type ProgressHandler = (progressEvent: any) => void;

export function createTrackableRequest(
    requestFunction: (progressHandler: ProgressHandler) => () => Promise<AxiosResponse>,
开发者ID:vanilla,项目名称:vanilla,代码行数:31,代码来源:apiv2.ts


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