Skip to content

Commit

Permalink
Fix: hostname missing (#587)
Browse files Browse the repository at this point in the history
* fix: hostname missing from documentation

* url encode the query

* remove characters from shared query with empty request body
  • Loading branch information
thewahome committed Jun 24, 2020
1 parent 79dd553 commit 9717c8c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/app/views/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, { Component } from 'react';
import { InjectedIntl, injectIntl } from 'react-intl';
import { connect } from 'react-redux';
import { bindActionCreators, Dispatch } from 'redux';

import { geLocale } from '../../appLocale';
import { loadGETheme } from '../../themes';
import { ThemeContext } from '../../themes/theme-context';
Expand All @@ -20,6 +21,7 @@ import { clearTermsOfUse } from '../services/actions/terms-of-use-action-creator
import { changeThemeSuccess } from '../services/actions/theme-action-creator';
import { toggleSidebar } from '../services/actions/toggle-sidebar-action-creator';
import { logIn } from '../services/graph-client/msal-service';
import { GRAPH_URL } from '../services/graph-constants';
import { parseSampleUrl } from '../utils/sample-url-generation';
import { substituteTokens } from '../utils/token-helpers';
import { appTitleDisplayOnFullScreen, appTitleDisplayOnMobileScreen } from './app-sections/AppTitle';
Expand Down Expand Up @@ -137,7 +139,7 @@ class App extends Component<IAppProps, IAppState> {
const request = urlParams.get('request');
const method = urlParams.get('method');
const version = urlParams.get('version');
const graphUrl = urlParams.get('GraphUrl');
const graphUrl = urlParams.get('GraphUrl') || GRAPH_URL;
const requestBody = urlParams.get('requestBody');
const headers = urlParams.get('headers');

Expand All @@ -155,7 +157,7 @@ class App extends Component<IAppProps, IAppState> {
sampleUrl: `${graphUrl}/${version}/${request}`,
selectedVerb: method,
selectedVersion: version,
sampleBody: this.hashDecode(requestBody),
sampleBody: requestBody ? this.hashDecode(requestBody) : null,
sampleHeaders: (headers) ? JSON.parse(this.hashDecode(headers)) : [],
};
}
Expand Down
15 changes: 7 additions & 8 deletions src/app/views/common/share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ export const createShareLink = (sampleQuery: IQuery, authenticated?: boolean): s
const url = new URL(sampleUrl);
const graphUrl = url.origin;
const appUrl = 'https://developer.microsoft.com/' + geLocale.toLowerCase() + '/graph/graph-explorer';
/**
* To ensure backward compatibility the version is removed from the pathname.
* V3 expects the request query param to not have the version number.
*/
const graphUrlRequest = requestUrl + search;
const requestBody = hashEncode(JSON.stringify(sampleBody));

const graphUrlRequest = encodeURIComponent(requestUrl + search);
let shareLink =
// tslint:disable-next-line:max-line-length
`${appUrl}?request=${graphUrlRequest}&method=${selectedVerb}&version=${queryVersion}&GraphUrl=${graphUrl}&requestBody=${requestBody}`;
`${appUrl}?request=${graphUrlRequest}&method=${selectedVerb}&version=${queryVersion}&GraphUrl=${graphUrl}`;

if (sampleBody && Object.keys(sampleBody).length > 0) {
const requestBody = hashEncode(JSON.stringify(sampleBody));
shareLink = `&requestBody=${requestBody}`;
}

if (sampleHeaders && sampleHeaders.length > 0) {
const headers = hashEncode(JSON.stringify(sampleHeaders));
Expand All @@ -41,7 +41,6 @@ export const createShareLink = (sampleQuery: IQuery, authenticated?: boolean): s
shareLink = `${shareLink}&sid=${sessionId}`;
}
}

return shareLink;
};

Expand Down

0 comments on commit 9717c8c

Please sign in to comment.