How to use the @vssue/utils.getCleanURL function in @vssue/utils

To help you get started, we’ve selected a few @vssue/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github meteorlxy / vssue / packages / vssue / dist / vssue.js View on Github external
// get issue according to title first
                        _a.issue = _c.sent();
                        if (!!this.issue) return [3 /*break*/, 3];
                        // require login to create the issue
                        if (!this.authStatus.isLogined) {
                            this.$emit('login');
                        }
                        // if current user is not admin, cannot create issue
                        if (!this.authStatus.isAdmin) {
                            throw Error('Failed to get comments');
                        }
                        // create the corresponding issue
                        _b = this;
                        return [4 /*yield*/, this.API.postIssue({
                                title: issueTitle,
                                content: getCleanURL(window.location.href),
                                accessToken: this.accessToken
                            })];
                    case 2:
                        // create the corresponding issue
                        _b.issue = _c.sent();
                        _c.label = 3;
                    case 3: 
                    // try to load comments
                    return [4 /*yield*/, this.getComments()];
                    case 4:
                        // try to load comments
                        _c.sent();
                        return [2 /*return*/];
                }
            });
        });
github meteorlxy / vssue / packages / vssue / dist / vssue.js View on Github external
if (!this.API || !this.options || this.issue || this.issueId)
            return;
        // login to create issue
        if (!this.isLogined) {
            this.login();
        }
        // only owner/admins can create issue
        if (!this.isAdmin)
            return;
        try {
            this.isCreatingIssue = true;
            const issue = await this.API.postIssue({
                title: this.issueTitle,
                content: await this.options.issueContent({
                    options: this.options,
                    url: getCleanURL(window.location.href),
                }),
                accessToken: this.accessToken,
            });
            this.issue = issue;
            this.isIssueNotCreated = false;
            await this.getComments();
        }
        catch (e) {
            this.isFailed = true;
        }
        finally {
            this.isCreatingIssue = false;
        }
    }
    /**
github meteorlxy / vssue / packages / @vssue / api-gitee-v5 / src / index.ts View on Github external
async handleAuth (): Promise {
    const query = parseQuery(window.location.search)
    if (query.code) {
      if (query.state !== this.state) {
        return null
      }
      const code = query.code
      delete query.code
      delete query.state
      const replaceURL = buildURL(getCleanURL(window.location.href), query) + window.location.hash
      window.history.replaceState(null, '', replaceURL)
      const accessToken = await this.getAccessToken({ code })
      return accessToken
    }
    return null
  }
github meteorlxy / vssue / packages / @vssue / api-bitbucket-v2 / lib / index.js View on Github external
return tslib_1.__generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        query = parseQuery(window.location.search);
                        if (!query.code) return [3 /*break*/, 2];
                        code = query.code;
                        delete query.code;
                        replaceURL = buildURL(getCleanURL(window.location.href), query) + window.location.hash;
                        window.history.replaceState(null, '', replaceURL);
                        return [4 /*yield*/, this.getAccessToken({ code: code })];
                    case 1:
                        accessToken = _a.sent();
                        return [2 /*return*/, accessToken];
                    case 2: return [2 /*return*/, null];
                }
            });
        });
github meteorlxy / vssue / packages / @vssue / api-github-v3 / src / index.ts View on Github external
async handleAuth (): Promise {
    const query = parseQuery(window.location.search)
    if (query.code) {
      if (query.state !== this.state) {
        return null
      }
      const code = query.code
      delete query.code
      delete query.state
      const replaceURL = buildURL(getCleanURL(window.location.href), query) + window.location.hash
      window.history.replaceState(null, '', replaceURL)
      const accessToken = await this.getAccessToken({ code })
      return accessToken
    }
    return null
  }
github meteorlxy / vssue / packages / @vssue / api-coding / src / index.ts View on Github external
async handleAuth (): Promise {
    const query = parseQuery(window.location.search)
    if (query.code) {
      const code = query.code
      delete query.code
      const replaceURL = buildURL(getCleanURL(window.location.href), query) + window.location.hash
      window.history.replaceState(null, '', replaceURL)
      const accessToken = await this.getAccessToken({ code })
      return accessToken
    }
    return null
  }
github meteorlxy / vssue / packages / @vssue / api-gitlab-v4 / src / index.ts View on Github external
async handleAuth (): Promise {
    const hash = parseQuery(window.location.hash.slice(1))
    if (!hash.access_token || hash.state !== this.state) {
      return null
    }
    const accessToken = hash.access_token
    delete hash.access_token
    delete hash.token_type
    delete hash.expires_in
    delete hash.state
    const hashString = buildQuery(hash)
    const newHash = hashString ? `#${hashString}` : ''
    const replaceURL = `${getCleanURL(window.location.href)}${window.location.search}${newHash}`
    window.history.replaceState(null, '', replaceURL)
    return accessToken
  }
github meteorlxy / vssue / packages / @vssue / api-github-v3 / lib / index.js View on Github external
return tslib_1.__generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        query = parseQuery(window.location.search);
                        if (!query.code) return [3 /*break*/, 2];
                        if (query.state !== this.state) {
                            return [2 /*return*/, null];
                        }
                        code = query.code;
                        delete query.code;
                        delete query.state;
                        replaceURL = buildURL(getCleanURL(window.location.href), query) + window.location.hash;
                        window.history.replaceState(null, '', replaceURL);
                        return [4 /*yield*/, this.getAccessToken({ code: code })];
                    case 1:
                        accessToken = _a.sent();
                        return [2 /*return*/, accessToken];
                    case 2: return [2 /*return*/, null];
                }
            });
        });
github meteorlxy / vssue / packages / vssue / dist / vssue.common.js View on Github external
get: function () {
            return utils.getCleanURL(window.location.href);
        },
        enumerable: true,
github meteorlxy / vssue / packages / @vssue / api-gitea-v1 / src / index.ts View on Github external
async handleAuth (): Promise {
    const query = parseQuery(window.location.search)
    if (query.code) {
      if (query.state !== this.state) {
        return null
      }
      const code = query.code
      delete query.code
      delete query.state
      const replaceURL = buildURL(getCleanURL(window.location.href), query) + window.location.hash
      window.history.replaceState(null, '', replaceURL)
      const accessToken = await this.getAccessToken({ code })
      return accessToken
    }
    return null
  }