Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async _onNavigationStateChange(webViewState) {
const { url } = webViewState
const { key } = this.state
if (webViewState.title === 'Instagram' && webViewState.url === 'https://www.instagram.com/') {
this.setState({ key: key + 1 })
}
if (url && url.startsWith(this.props.redirectUrl)) {
const match = url.match(/(#|\?)(.*)/)
const results = qs.parse(match[2])
this.hide()
if (results.access_token) {
// Keeping this to keep it backwards compatible, but also returning raw results to account for future changes.
this.props.onLoginSuccess(results.access_token, results)
} else if (results.code) {
//Fetching to get token with appId, appSecret and code
let { code } = results
code = code.split('#_').join('')
const { appId, appSecret, redirectUrl, scopes } = this.props
let headers = { 'Content-Type': 'application/x-www-form-urlencoded' }
let http = axios.create({ baseURL: 'https://api.instagram.com/oauth/access_token', headers: headers })
let form = new FormData();
form.append( 'app_id', appId );
form.append( 'app_secret', appSecret );
form.append( 'grant_type', 'authorization_code' );
handleEnvironmentQueryParam() {
let queryString = this.props.location.search;
queryString = queryString.replace(/^\?/, '');
/* With QS version up we can directly use {ignoreQueryPrefix: true} option */
const queryParams = qs.parse(queryString);
const environmentName = queryParams.environment;
if (!environmentName || this.environmentName === environmentName) {
// no environment query param or the same environment
return;
}
const environmentId = Utils.getEnvironmentID(this.state.environments, environmentName);
if (environmentId === -1) {
console.error('Invalid environment name in environment query parameter.');
return;
}
const environment = this.state.environments[environmentId];
Utils.setEnvironment(environment);
this.environmentName = environmentName;
let parts = url.split('#');
let hash = parts[1];
let partsWithoutHash = parts[0].split('?');
let queryString = partsWithoutHash[partsWithoutHash.length - 1];
// Get query string (?hello=world)
let parsedSearch = qs.parse(queryString);
// Pull errorCode off of params
let { errorCode } = parsedSearch;
delete parsedSearch.errorCode;
// Get hash (#abc=example)
let parsedHash = {};
if (parts[1]) {
parsedHash = qs.parse(hash);
}
// Merge search and hash
let params = {
...parsedSearch,
...parsedHash,
};
return {
errorCode,
params,
};
}
Promise.resolve().then(() => {
let search = window.location.search.slice(1)
let params = qs.parse(search)
Object.assign(params, plannedParams)
params = sorted(params)
let str = qs.stringify(params, { encode: false })
// ignore unchanged transition
if (str === search) return
window.history.replaceState(null, '', str ? '?' + str : window.location.href.split('?')[0])
plannedTimeout = null
plannedParams = {}
})
}
const wired = ({ url, type, body }) => ({
method: type,
params: qs.parse(url.split('?').length > 1 ? url.split('?')[1] : ''),
body: JSON.parse(body),
url: qs.parse(url.split('?')[0]),
...CustomExtends
})
Request.prototype.oauth = function (_oauth) {
var form
if (this.headers['content-type'] &&
this.headers['content-type'].slice(0, 'application/x-www-form-urlencoded'.length) ===
'application/x-www-form-urlencoded'
) {
form = qs.parse(this.body)
}
if (this.uri.query) {
form = qs.parse(this.uri.query)
}
if (!form) form = {}
var oa = {}
for (var i in form) oa[i] = form[i]
for (var i in _oauth) oa['oauth_'+i] = _oauth[i]
if (!oa.oauth_version) oa.oauth_version = '1.0'
if (!oa.oauth_timestamp) oa.oauth_timestamp = Math.floor( Date.now() / 1000 ).toString()
if (!oa.oauth_nonce) oa.oauth_nonce = uuid().replace(/-/g, '')
oa.oauth_signature_method = 'HMAC-SHA1'
var consumer_secret = oa.oauth_consumer_secret
delete oa.oauth_consumer_secret
var token_secret = oa.oauth_token_secret
delete oa.oauth_token_secret
var timestamp = oa.oauth_timestamp
const TranslationsEntities: React.FC = ({
location,
match
}) => {
const qs = parseQs(location.search.substr(1));
return (
);
};
type TranslationsEntityRouteProps = RouteComponentProps<{
const getDefaultFormFromLocation = location => {
const companyName = qs.parse(location.search, { ignoreQueryPrefix: true })
.companyName;
if (companyName) {
return {
...defaultForm,
company: companyName,
};
}
return null;
};
export const parseQuery = (rawQuery = currentRawQuery()) => qs.parse(rawQuery)