Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 => {
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) {
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, '')
}
export function getParamFromURL(url: string, param: string): string | undefined {
return qs.parse(qs.extract(url))[param];
}
getQuery() {
const decodedUrl = decodeURIComponent(this.url);
const extractedQuery = queryString.extract(decodedUrl);
const query = queryString.parse(extractedQuery);
return query;
}
function addQueryParams (url, router) {
const { asPath } = router
const query = queryString.extract(asPath)
return query.length ? `${url}?${query}` : url
}
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)
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, '')
}
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;
}
getStringifiedQuery() {
const decodedUrl = decodeURIComponent(this.url);
return queryString.extract(decodedUrl);
}
}