How to use the query-string.parseUrl 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 DivanteLtd / vue-storefront / core / server-entry.ts View on Github external
export default async context => {
  let storeCode = context.vs.storeCode
  if (config.storeViews.multistore === true) {
    if (!storeCode) { // this is from url
      const currentRoute = Object.assign({ path: queryString.parseUrl(context.url).url/* this gets just the url path part */, host: context.server.request.headers.host })
      storeCode = storeCodeFromRoute(currentRoute)
    }
  }
  const { app, router, store, initialState } = await createApp(context, context.vs && context.vs.config ? context.vs.config : buildTimeConfig, storeCode)

  RouterManager.flushRouteQueue(router)
  context.initialState = initialState
  return new Promise((resolve, reject) => {
    context.output.cacheTags = new Set()
    const meta = (app as any).$meta()
    router.push(context.url)
    context.meta = meta
    router.onReady(() => {
      const matchedComponents = router.getMatchedComponents()
      if (!matchedComponents.length || !matchedComponents[0]) {
        return reject(new HttpError('No components matched', 404)) // TODO - don't redirect if already on page-not-found
github ChanceYu / front-end-rss / server / fetch.js View on Github external
function isSameLink(link, compare){
  link = link.replace(/&/g, '&');
  compare = compare.replace(/&/g, '&');

  const oLink = queryString.parseUrl(link);
  const oCompare = queryString.parseUrl(compare);

  if(/mp\.weixin/.test(oLink.url)){
    return (oLink.query.sn === oCompare.query.sn)
        && (oLink.query.mid === oCompare.query.mid)
  }else{
    return link === compare
  }
}
github shopgate / pwa / libraries / common / subscriptions / helpers / buildRegisterUrl.spec.js View on Github external
it('should create the expected url when a checkout redirect url was passed', () => {
    const result = queryString.parseUrl(buildRegisterUrl(`${LEGACY_URL}?foo=bar`, CHECKOUT_PATH));

    expect(result.url).toBe(LEGACY_URL);
    expect(result.query).toEqual({
      foo: 'bar',
      sgcloud_callback_data: `{"redirectTo":"${INDEX_PATH}"}`,
      sgcloud_checkout: '1',
    });
  });
});
github CrystallizeAPI / crystallize-frontend-boilerplate / pages / confirmation / index.js View on Github external
static async getInitialProps({ req }) {
    const { orderId, paymentMethod } = req.params;
    if (orderId) return { orderId, paymentMethod };

    const { query } = queryString.parseUrl(req.url);
    return { orderId: query.order_id, paymentMethod: query.payment_method };
  }
github go-faast / faast-web / src / utilities / fetch.ts View on Github external
const doFetchJson = () => Promise.resolve().then(() => {
    let encodedParams = {}
    if (path.includes('?')) {
      const parsed = qs.parseUrl(path)
      path = parsed.url
      encodedParams = parsed.query || {}
    }
    const allParams = {
      ...(method === 'GET' ? { _: Date.now() } : {}),
      ...encodedParams,
      ...params,
    }
    const allParamsString = qs.stringify(allParams)
    const fullPath = path + (allParamsString ? '?' + allParamsString : '')

    const headers: FetchHeaders = {
      ...(options.headers || {}),
      Accept: 'application/json',
    }
    let bodyString: string
github i-novus-llc / n2o-framework / frontend / n2o-framework / .storybook / fetchMock / getStubData.js View on Github external
export const parseUrl = (rawUrl) => {
  const parsedUrl = queryString.parseUrl(rawUrl);
  return parsedUrl.query;
};
github skmail / responsive-viewer / src / background.js View on Github external
chrome.webNavigation.onBeforeNavigate.addListener(function(details) {
  const isAllowed = isAllowedToAction(tabStorage.get(details.tabId))

  if (!isAllowed || details.frameId === 0) {
    return
  }

  if (details.parentFrameId === 0) {
    const parsed = queryString.parseUrl(details.url)

    let userAgent = parsed.query ? parsed.query.__userAgent__ : null

    if (userAgent) {
      frameStorage.set({
        ...details,
        userAgent,
      })
    }
  }
})
github macarthur-lab / gnomadjs / projects / gnomad / src / client / Searchbox.js View on Github external
onSelect={url => {
            const parsedUrl = queryString.parseUrl(url)
            const nextParams = { dataset: searchDataset }
            history.push({
              pathname: parsedUrl.url,
              search: queryString.stringify(nextParams),
            })
          }}
        />
github VaclavRut / actor-amazon-crawler / src / parseSellerDetail.js View on Github external
function buildSellerUrl(url) {
    const parsedUrl = queryString.parseUrl(url);
    return `${parsedUrl.url}/?seller=${parsedUrl.query.seller}`;
}
github iotexproject / iotex-explorer / src / electron / src / main.js View on Github external
app.on("open-url", function(event, url) {
  event.preventDefault();
  const { query } = queryString.parseUrl(url);
  log.debug("deeplink url with query params: " + JSON.stringify(query));

  if (mainWindow && mainWindow.webContents) {
    return mainWindow.webContents.send("query", query);
  }

  app.on("ready", () => {
    setTimeout(() => {
      return mainWindow.webContents.send("query", query);
    }, 3000);
  });
});

query-string

Parse and stringify URL query strings

MIT
Latest version published 4 months ago

Package Health Score

87 / 100
Full package analysis