How to use the query-string.extract function in query-string

To help you get started, we’ve selected a few query-string 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 OfficeDev / script-lab / packages / editor / src / index.tsx View on Github external
function getReactElementBasedOnQueryParams() {
  const params: { state?: string; code?: string } = queryString.parse(
    queryString.extract(window.location.href),
  );

  // For the GitHub auth callback, we've registered the root page.
  // To avoid needing to change it at the GitHub layer (and thus breaking it across
  // our redirected environments), it's best to stick with what the registration
  // already expects.  And so, if we see "state" and "code" on the URL --
  // which is a telltale sign of GitHub redirecting after successful auth --
  // got ahead and render the AuthPage component.
  if (params.state && params.code) {
    return ;
  } else {
    // Add a keyboard listener to [try to] intercept "ctrl+save", since we auto-save anyway
    // and since the browser/host "save as" dialog would be unwanted here
    document.addEventListener(
      'keydown',
      e => {
github wheatandcat / Peperomia / PeperomiaNative / src / components / pages / LoginWithAmazon / Connected.tsx View on Github external
redirect = async (event: any) => {
    Linking.removeEventListener('url', e => this.redirect(e));

    const result = (await queryString.parse(
      queryString.extract(event.url)
    )) as WebPageResponse;

    if (!this.props.post) {
      return;
    }

    try {
      const request = {
        accessToken: result.accessToken.split('?')[0],
      };

      const response = await this.props.post('LoginWithAmazon', {
        body: JSON.stringify(request),
      });

      if (!response.ok) {
github PCreations / redux-paginator / src / agent.js View on Github external
let finalParsedParams = {}
  let startString = ''
  for (let key of Object.keys(parsedParams)) {
    if (parsedParams[key] == null) {
      startString += key
    }
    else {
      finalParsedParams = {
        ...finalParsedParams,
        [key]: parsedParams[key]
      }
    }
  }
  startString = startString == '' ? '?' : startString + '?'

  if (Object.keys(finalParsedParams).length > 0 && qs.extract(params) != '') {
    startString = params.replace(qs.extract(params), '')
  }
  return startString+qs.stringify({
    ...finalParsedParams,
    [pageArgName]: page
  }, { encode: false }).replace(startString, '')
}
github MyCryptoHQ / MyCrypto / common / v2 / libs / helpers.ts View on Github external
export function getParamFromURL(url: string, param: string): string | undefined {
  return qs.parse(qs.extract(url))[param];
}
github iamport / iamport-react-native / src / utils / IamportUrl.js View on Github external
getQuery() {
    const decodedUrl = decodeURIComponent(this.url);
    const extractedQuery = queryString.extract(decodedUrl);
    const query = queryString.parse(extractedQuery);
    return query;
  }
github zooniverse / front-end-monorepo / packages / app-project / src / helpers / addQueryParams / addQueryParams.js View on Github external
function addQueryParams (url, router) {
  const { asPath } = router
  const query = queryString.extract(asPath)
  return query.length ? `${url}?${query}` : url
}
github muffin / server / routes / api.js View on Github external
router.get('/reset-password', function *(next) {
  const queries = queryString.extract(this.request.originalUrl)
  const _id = queryString.parse(queries).name

  if (!_id) {
    this.body = {
      error: 'No username'
    }

    return
  }

  const query = User.where({ _id })

  try {
    var user = yield query.findOne()
  } catch (err) {
    log('Couldn\'t load user', err)
github PCreations / redux-paginator / src / agent.js View on Github external
let startString = ''
  for (let key of Object.keys(parsedParams)) {
    if (parsedParams[key] == null) {
      startString += key
    }
    else {
      finalParsedParams = {
        ...finalParsedParams,
        [key]: parsedParams[key]
      }
    }
  }
  startString = startString == '' ? '?' : startString + '?'

  if (Object.keys(finalParsedParams).length > 0 && qs.extract(params) != '') {
    startString = params.replace(qs.extract(params), '')
  }
  return startString+qs.stringify({
    ...finalParsedParams,
    [pageArgName]: page
  }, { encode: false }).replace(startString, '')
}
github imagemin / imagemin-micro / index.js View on Github external
module.exports = req => micro.buffer(req, {limit: '10mb'}).then(buf => {
	const query = queryString.parse(queryString.extract(req.url));
	const url = query.url;

	delete query.url;

	const plugins = [
		imageminGifsicle(query),
		imageminJpegtran(query),
		imageminOptipng(query),
		imageminSvgo(query)
	];

	if (!url && buf.length === 0) {
		const err = new Error('Expected a Buffer or URL');
		err.statusCode = 400;
		throw err;
	}
github iamport / iamport-react-native / src / utils / IamportUrl.js View on Github external
getStringifiedQuery() {
    const decodedUrl = decodeURIComponent(this.url);
    return queryString.extract(decodedUrl);
  }
}

query-string

Parse and stringify URL query strings

MIT
Latest version published 1 month ago

Package Health Score

91 / 100
Full package analysis