How to use the aurelia-path.buildQueryString function in aurelia-path

To help you get started, we’ve selected a few aurelia-path 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 SpoonX / aurelia-api / src / rest.js View on Github external
request(method: string, path: string, body?: {}, options?: {}, responseOutput?: { response: Response}): Promise {
    let requestOptions = extend(true, {headers: {}}, this.defaults || {}, options || {}, {method, body});
    let contentType    = requestOptions.headers['Content-Type'] || requestOptions.headers['content-type'];

    // if body is object, stringify to json or urlencoded depending on content-type
    if (typeof body === 'object' && body !== null && contentType) {
      requestOptions.body = (/^application\/(.+\+)?json/).test(contentType.toLowerCase())
                          ? JSON.stringify(body)
                          : buildQueryString(body);
    }

    return this.client.fetch(path, requestOptions).then((response: Response) => {
      if (response.status >= 200 && response.status < 400) {
        if (responseOutput) {
          responseOutput.response = response;
        }

        return response.json().catch(() => null);
      }

      throw response;
    });
  }
github aurelia / route-recognizer / dist / aurelia-route-recognizer.js View on Github external
} else {
        output += '/';
        output += segmentValue;
      }
    }

    if (output.charAt(0) !== '/') {
      output = '/' + output;
    }

    // remove params used in the path and add the rest to the querystring
    for (let param in consumed) {
      delete routeParams[param];
    }

    let queryString = buildQueryString(routeParams);
    output += queryString ? `?${queryString}` : '';

    return output;
  }
github Mordred / aurelia-sails-socket-client / src / socket-request-message.js View on Github external
function buildFullUrl(message) {
  let url;
  let qs;

  // Message URL starts with / - as absolute URL
  if (message.url && message.url[0] === '/') {
    url = message.url;
  } else {
    url = join(message.baseUrl, message.url);
  }

  if (message.params) {
    qs = buildQueryString(message.params);
    url = qs ? `${url}?${qs}` : url;
  }

  return url;
}
github aurelia / http-client / src / request-message.js View on Github external
buildFullUrl(): string {
    let absoluteUrl = /^([a-z][a-z0-9+\-.]*:)?\/\//i;
    let url = absoluteUrl.test(this.url) ? this.url : join(this.baseUrl, this.url);

    if (this.params) {
      let qs = buildQueryString(this.params);
      url = qs ? url + (this.url.indexOf('?') < 0 ? '?' : '&') + qs : url;
    }

    return url;
  }
}
github cmichaelgraham / aurelia-typescript / aurelia-ts-lib / aurelia-ts / http-client / request-message-processor.ts View on Github external
function buildFullUri(message){
  var uri = join(message.baseUrl, message.uri),
      qs;

  if(message.params){
    qs = buildQueryString(message.params);
    uri = qs ? `${uri}?${qs}` : uri;
  }

  message.fullUri = uri;
}
github SpoonX / aurelia-api / dist / es2015 / aurelia-api.js View on Github external
function getRequestPath(resource, traditional, idOrCriteria, criteria) {
  let hasSlash = resource.slice(-1) === '/';

  if (typeof idOrCriteria === 'string' || typeof idOrCriteria === 'number') {
    resource = `${join(resource, String(idOrCriteria))}${hasSlash ? '/' : ''}`;
  } else {
    criteria = idOrCriteria;
  }

  if (typeof criteria === 'object' && criteria !== null) {
    resource += `?${buildQueryString(criteria, traditional)}`;
  } else if (criteria) {
    resource += `${hasSlash ? '' : '/'}${criteria}${hasSlash ? '/' : ''}`;
  }

  return resource;
}
github SpoonX / aurelia-api / src / rest.js View on Github external
function getRequestPath(resource: string, traditional: boolean, idOrCriteria?: string|number|{}, criteria?: {}) {
  let hasSlash = resource.slice(-1) === '/';

  if (typeof idOrCriteria === 'string' || typeof idOrCriteria === 'number') {
    resource = `${join(resource, String(idOrCriteria))}${hasSlash ? '/' : ''}`;
  } else {
    criteria = idOrCriteria;
  }

  if (typeof criteria === 'object' && criteria !== null) {
    resource += `?${buildQueryString(criteria, traditional)}`;
  } else if (criteria) {
    resource += `${hasSlash ? '' : '/'}${criteria}${hasSlash ? '/' : ''}`;
  }

  return resource;
}
github aurelia / http-client / dist / es6 / request-message-processor.js View on Github external
function buildFullUrl(message){
  var url = join(message.baseUrl, message.url),
      qs;

  if(message.params){
    qs = buildQueryString(message.params);
    url = qs ? `${url}?${qs}` : url;
  }

  message.fullUrl = url;
}
github Mordred / aurelia-sails-socket-client / dist / es2015 / aurelia-sails-socket-client.js View on Github external
function buildFullUrl(message) {
  let url;
  let qs;

  if (message.url && message.url[0] === '/') {
    url = message.url;
  } else {
    url = join(message.baseUrl, message.url);
  }

  if (message.params) {
    qs = buildQueryString(message.params);
    url = qs ? `${url}?${qs}` : url;
  }

  return url;
}
github Kukks / aurelia-miningcore-ui / src / pool / pool-blocks / pool-blocks.ts View on Github external
if (!this.poolId) {
      return;
    }
    if (this.timeout) {
      try {
        clearTimeout(this.timeout);
      } catch{ }
    }
    this.error = false;
    let options = {
      pageSize: this.pageSize,
      page: this.currentPageNumber
    }


    this.apiClientService.http.get(`pools/${this.poolId}/blocks?${buildQueryString(options, true)}`).then((value: HttpResponseMessage) => {
      if (value.isSuccess) {
        if (this.currentPageNumber === 0) {
          this.data = [];
        }
        this.data = [...this.data, ...value.content];
      } else {
        this.error = true;
      }
    }).catch(() => {
      this.error = true;
    }).then(() => {
      this.loading = false;
      this.timeout = setTimeout(this.refresh.bind(this), 4000);
    })
  }
}

aurelia-path

Utilities for path manipulation.

MIT
Latest version published 4 months ago

Package Health Score

67 / 100
Full package analysis