How to use the @vssue/utils.concatURL 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 / api-gitee-v5 / src / index.ts View on Github external
/* istanbul ignore if */
    if (typeof clientSecret === 'undefined' || typeof proxy === 'undefined') {
      throw new Error('clientSecret and proxy is required for Gitee V5')
    }
    this.baseURL = baseURL
    this.owner = owner
    this.repo = repo
    this.labels = labels

    this.clientId = clientId
    this.clientSecret = clientSecret
    this.state = state
    this.proxy = proxy

    this.$http = axios.create({
      baseURL: concatURL(baseURL, 'api/v5'),
    })

    this.$http.interceptors.response.use(response => response, error => {
      if (error.response.data && error.response.data.message) {
        error.message = error.response.data.message
      }
      return Promise.reject(error)
    })
  }
github meteorlxy / vssue / packages / @vssue / api-github-v4 / src / index.ts View on Github external
async getAccessToken ({
    code,
  }: {
    code: string
  }): Promise {
    /**
     * access_token api does not support cors
     * @see https://github.com/isaacs/github/issues/330
     */
    const originalURL = concatURL(this.baseURL, 'login/oauth/access_token')
    const proxyURL = typeof this.proxy === 'function'
      ? this.proxy(originalURL)
      : this.proxy
    const { data } = await this.$http.post(proxyURL, {
      client_id: this.clientId,
      client_secret: this.clientSecret,
      code,
      /**
       * useless but mentioned in docs
       */
      // redirect_uri: window.location.href,
      // state: this.state,
    }, {
      headers: {
        'Accept': 'application/json',
      },
github meteorlxy / vssue / packages / @vssue / api-bitbucket-v2 / src / index.ts View on Github external
redirectAuth (): void {
    window.location.href = buildURL(concatURL(this.baseURL, 'site/oauth2/authorize'), {
      client_id: this.clientId,
      redirect_uri: window.location.href,
      response_type: 'token',
      state: this.state,
    })
  }
github meteorlxy / vssue / packages / @vssue / api-gitea-v1 / src / index.ts View on Github external
private apiURL (url) {
    return typeof this.proxy === 'function' ? this.proxy(concatURL(this.baseURL, `api/v1/${url}`)) : url
  }
github meteorlxy / vssue / packages / @vssue / api-gitea-v1 / src / index.ts View on Github external
async getAccessToken ({
    code,
  }: {
    code: string
  }): Promise {
    const originalURL = concatURL(this.baseURL, 'login/oauth/access_token')
    const proxyURL = typeof this.proxy === 'function'
      ? this.proxy(originalURL)
      : this.proxy
    /**
     * JSON does not work
     *
     * @see https://github.com/go-gitea/gitea/issues/6624
     */
    const { data } = await this.$http.post(proxyURL, buildQuery({
      'client_id': this.clientId,
      'client_secret': this.clientSecret,
      'code': code,
      'grant_type': 'authorization_code',
      'redirect_uri': window.location.href,
    }), {
      headers: {
github meteorlxy / vssue / packages / @vssue / api-gitea-v1 / src / utils.ts View on Github external
export function normalizeUser (user: any, baseURL: string): VssueAPI.User {
  return {
    username: user.login,
    avatar: user.avatar_url,
    homepage: concatURL(baseURL, user.login),
  }
}
github meteorlxy / vssue / packages / @vssue / api-gitee-v5 / src / index.ts View on Github external
redirectAuth (): void {
    window.location.href = buildURL(concatURL(this.baseURL, 'oauth/authorize'), {
      client_id: this.clientId,
      redirect_uri: window.location.href,
      scope: 'user_info issues notes',
      response_type: 'code',
      state: this.state,
    })
  }
github meteorlxy / vssue / packages / @vssue / api-github-v3 / src / index.ts View on Github external
redirectAuth (): void {
    window.location.href = buildURL(concatURL(this.baseURL, 'login/oauth/authorize'), {
      client_id: this.clientId,
      redirect_uri: window.location.href,
      scope: 'public_repo',
      state: this.state,
    })
  }