How to use the urijs.parseQuery function in urijs

To help you get started, we’ve selected a few urijs 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 chanzuckerberg / cellxgene / src / reducers / selectedMetadata.js View on Github external
const selectedMetadata = (
  state = {},
  action
) => {
  switch (action.type) {
    case "url changed": {
      const {url} = action;
      const parsed = uri.parseQuery(window.location.search);
      // console.log("onURLchange sees: ", state, parsed)
      return state;
    }
    case "categorical metadata filter selected success": {
      if (!state[action.metadataField]) { /* we don't have the field, which means this is a simple insertion */
        /* {} becomes {Location: ["Tumor"]} */
        return Object.assign({}, state, {[action.metadataField]: [action.value]});
      } else { /* we do have the field, so we need to push to a copy of the array */
        const updatedField = state[action.metadataField].slice()
        updatedField.push(action.value)
        return Object.assign({}, state, {
          /* {Location: ["Tumor"]} becomes {Location: ["Tumor", "Periphery"]} */
          [action.metadataField]: updatedField
        })
      }
    }
github faouzioudouh / youtube / src / store / currentStore.ts View on Github external
import URI from 'urijs';
import configureStore from './configureStore';

const urlParsed = URI.parseQuery(document.location.search);
const initialState = {
    urlVideoId: urlParsed['v'] || '814eR5K7KD8',
};

// The instance of the current store shared in the application.
const currentStore = configureStore(initialState);

currentStore.subscribe(() => {
    const currentVideo = currentStore.getState().currentVideo;
    if (currentVideo) {
        const newUrl = URI(document.location.href).query({v:  currentVideo.id }).toString();
        history.pushState(null, '', newUrl);
    }
});

export default currentStore;
github stream-labs / streamlabs-obs / app / services / user.ts View on Github external
private parseAuthFromUrl(url: string, merge: boolean): IUserAuth {
    const query = URI.parseQuery(URI.parse(url).query) as Dictionary;
    const requiredFields = ['platform', 'platform_username', 'platform_token', 'platform_id'];

    if (!merge) requiredFields.push('token', 'oauth_token');

    if (requiredFields.every(field => !!query[field])) {
      return {
        widgetToken: merge ? this.widgetToken : query.token,
        apiToken: merge ? this.apiToken : query.oauth_token,
        primaryPlatform: query.platform as TPlatform,
        platforms: {
          [query.platform]: {
            type: query.platform,
            username: query.platform_username,
            token: query.platform_token,
            id: query.platform_id,
          },
github kiwicom / the-zoo / zoo / analytics / assets / js / analytics_overview.js View on Github external
$(document).ready(() => {
    const currentUrl = URI(window.location.href)
    queryParams = URI.parseQuery(currentUrl.query())

    if(queryParams.hasOwnProperty('q'))
        searchInput.val(queryParams.q)

    if(queryParams.hasOwnProperty('type')) {
        typeDropdown.dropdown('set selected', queryParams.type)
    }

    $('.version-chart').each((index, element) => {
        const chartElement = $(element)
        new Chart(
            document.getElementById($(element).attr('id')).getContext('2d'),
            {
                type: 'horizontalBar',
                data: {
                    labels: ["Versions"],
github stream-labs / streamlabs-obs / app / services / utils.ts View on Github external
static getUrlParams(url: string) {
    return URI.parseQuery(URI.parse(url).query) as Dictionary;
  }
github OpenStackweb / openstack-org / marketplace / ui / source / js / marketplace-driver-page / MarketplaceDriverApp.js View on Github external
constructor(props) {
        super(props);


        let project_filter = 'all', release_filter = 'all', vendor_filter = 'all';

        if(window.location.hash) {
            let hash = URI.parseQuery(window.location.hash.substr(1));
            if (('project' in hash) && hash['project']) {
                project_filter = hash['project'];
            }
            if (('vendor' in hash) && hash['vendor']) {
                vendor_filter = hash['vendor'];
            }
            if (('release' in hash) && hash['release']) {
                release_filter = hash['release'];
            }
        }

        this.state = {
            sort_direction  : SortDirectionAsc,
            sort_field      : 'Project',
            project         : project_filter,
            release         : release_filter,
github stream-labs / streamlabs-obs / app / services / integrations / twitter.ts View on Github external
private parseTwitterResultFromUrl(url: string) {
    const query = URI.parseQuery(URI.parse(url).query) as Dictionary;
    if (query.twitter) {
      return { success: !!query.success };
    }

    return false;
  }
}
github szy0syz / react-qunar-pwa / train-ticket / src / query / App.jsx View on Github external
useEffect(() => {
    const queries = URI.parseQuery(window.location.search);

    const { from, to, date, highSpeed } = queries;

    dispatch(setFrom(from));
    dispatch(setTo(to));
    dispatch(setDepartDate(h0(dayjs(date).valueOf())));
    dispatch(setHighSpeed(highSpeed === 'true'));

    dispatch(setSearchParsed(true));
  }, [dispatch]);