2017-07-20 01:55:40 +00:00
|
|
|
// @flow
|
2018-06-25 17:42:50 +00:00
|
|
|
import type { Request } from '../models/request';
|
|
|
|
import type { BaseModel } from '../models/index';
|
2017-07-20 01:55:40 +00:00
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
import { setDefaultProtocol } from 'insomnia-url';
|
2017-02-20 18:32:27 +00:00
|
|
|
import clone from 'clone';
|
2016-11-10 05:56:23 +00:00
|
|
|
import * as models from '../models';
|
2018-06-28 03:43:38 +00:00
|
|
|
import { CONTENT_TYPE_GRAPHQL } from '../common/constants';
|
2016-11-10 01:15:27 +00:00
|
|
|
import * as db from './database';
|
2017-02-20 18:32:27 +00:00
|
|
|
import * as templating from '../templating';
|
2018-06-25 17:42:50 +00:00
|
|
|
import type { CookieJar } from '../models/cookie-jar';
|
|
|
|
import type { Environment } from '../models/environment';
|
2016-04-15 02:13:49 +00:00
|
|
|
|
2017-07-11 01:05:54 +00:00
|
|
|
export const KEEP_ON_ERROR = 'keep';
|
|
|
|
export const THROW_ON_ERROR = 'throw';
|
2018-06-09 03:22:39 +00:00
|
|
|
|
|
|
|
export type RenderPurpose = 'send' | 'general';
|
|
|
|
|
|
|
|
export const RENDER_PURPOSE_SEND: RenderPurpose = 'send';
|
|
|
|
export const RENDER_PURPOSE_GENERAL: RenderPurpose = 'general';
|
2017-07-11 01:05:54 +00:00
|
|
|
|
2017-07-20 01:55:40 +00:00
|
|
|
export type RenderedRequest = Request & {
|
2018-06-25 17:42:50 +00:00
|
|
|
cookies: Array<{ name: string, value: string, disabled?: boolean }>,
|
2017-08-22 22:30:57 +00:00
|
|
|
cookieJar: CookieJar
|
2017-07-20 01:55:40 +00:00
|
|
|
};
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
export async function buildRenderContext(
|
2017-07-20 01:55:40 +00:00
|
|
|
ancestors: Array<BaseModel> | null,
|
2017-09-25 21:32:58 +00:00
|
|
|
rootEnvironment: Environment | null,
|
|
|
|
subEnvironment: Environment | null,
|
2017-07-20 01:55:40 +00:00
|
|
|
baseContext: Object = {}
|
|
|
|
): Object {
|
2017-09-25 21:32:58 +00:00
|
|
|
const envObjects = [];
|
2016-09-03 04:32:45 +00:00
|
|
|
|
|
|
|
if (rootEnvironment) {
|
2017-09-25 21:32:58 +00:00
|
|
|
envObjects.push(rootEnvironment.data);
|
2016-09-03 04:32:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (subEnvironment) {
|
2017-09-25 21:32:58 +00:00
|
|
|
envObjects.push(subEnvironment.data);
|
2016-09-03 04:32:45 +00:00
|
|
|
}
|
|
|
|
|
2017-07-20 01:55:40 +00:00
|
|
|
for (const doc of (ancestors || []).reverse()) {
|
2018-03-29 17:59:32 +00:00
|
|
|
const environment = (doc: any).environment;
|
|
|
|
if (typeof environment === 'object' && environment !== null) {
|
|
|
|
envObjects.push(environment);
|
2016-09-03 04:32:45 +00:00
|
|
|
}
|
2017-01-13 19:21:03 +00:00
|
|
|
}
|
2016-09-03 04:32:45 +00:00
|
|
|
|
2017-01-24 18:51:25 +00:00
|
|
|
// At this point, environments is a list of environments ordered
|
|
|
|
// from top-most parent to bottom-most child
|
2017-05-15 20:55:05 +00:00
|
|
|
// Do an Object.assign, but render each property as it overwrites. This
|
|
|
|
// way we can keep same-name variables from the parent context.
|
2017-07-11 01:05:54 +00:00
|
|
|
const renderContext = baseContext;
|
2017-09-25 21:32:58 +00:00
|
|
|
for (const envObject: Object of envObjects) {
|
2017-11-27 15:52:35 +00:00
|
|
|
const keys = _getOrderedEnvironmentKeys(envObject);
|
2017-05-15 20:55:05 +00:00
|
|
|
for (const key of keys) {
|
|
|
|
/*
|
2018-06-29 16:29:46 +00:00
|
|
|
* If we're overwriting a string, try to render it first using the same key from the base
|
|
|
|
* environment to support same-variable recursion. This allows for the following scenario:
|
2017-05-15 20:55:05 +00:00
|
|
|
*
|
|
|
|
* base: { base_url: 'google.com' }
|
|
|
|
* obj: { base_url: '{{ base_url }}/foo' }
|
|
|
|
* final: { base_url: 'google.com/foo' }
|
|
|
|
*
|
|
|
|
* A regular Object.assign would yield { base_url: '{{ base_url }}/foo' } and the
|
|
|
|
* original base_url of google.com would be lost.
|
|
|
|
*/
|
|
|
|
if (typeof renderContext[key] === 'string') {
|
2018-06-29 16:29:46 +00:00
|
|
|
const rendered = await render(
|
2017-09-25 21:32:58 +00:00
|
|
|
envObject[key],
|
2018-06-29 16:29:46 +00:00
|
|
|
{ [key]: renderContext[key] }, // Only render with key being overwritten
|
2017-07-11 01:05:54 +00:00
|
|
|
null,
|
|
|
|
KEEP_ON_ERROR,
|
|
|
|
'Environment'
|
|
|
|
);
|
2018-06-29 16:29:46 +00:00
|
|
|
|
|
|
|
// Only use rendered version if rendering actually yielded something different.
|
|
|
|
renderContext[key] =
|
|
|
|
rendered !== envObject[key] ? rendered : envObject[key];
|
2017-05-15 20:55:05 +00:00
|
|
|
} else {
|
2017-09-25 21:32:58 +00:00
|
|
|
renderContext[key] = envObject[key];
|
2017-05-15 20:55:05 +00:00
|
|
|
}
|
|
|
|
}
|
2016-09-03 04:32:45 +00:00
|
|
|
}
|
|
|
|
|
2017-01-24 18:51:25 +00:00
|
|
|
// Render the context with itself to fill in the rest.
|
2017-02-07 16:09:12 +00:00
|
|
|
let finalRenderContext = renderContext;
|
|
|
|
|
2017-07-11 01:05:54 +00:00
|
|
|
// Render recursive references.
|
2017-11-27 15:52:35 +00:00
|
|
|
const keys = _getOrderedEnvironmentKeys(finalRenderContext);
|
2017-02-07 16:09:12 +00:00
|
|
|
for (let i = 0; i < 3; i++) {
|
2017-11-27 15:52:35 +00:00
|
|
|
for (const key of keys) {
|
|
|
|
finalRenderContext[key] = await render(
|
|
|
|
finalRenderContext[key],
|
|
|
|
finalRenderContext,
|
|
|
|
null,
|
|
|
|
KEEP_ON_ERROR,
|
|
|
|
'Environment'
|
|
|
|
);
|
|
|
|
}
|
2017-02-07 16:09:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return finalRenderContext;
|
2016-10-02 20:57:00 +00:00
|
|
|
}
|
2016-09-03 04:32:45 +00:00
|
|
|
|
2017-02-20 18:32:27 +00:00
|
|
|
/**
|
|
|
|
* Recursively render any JS object and return a new one
|
2017-05-15 20:55:05 +00:00
|
|
|
* @param {*} obj - object to render
|
2017-02-20 18:32:27 +00:00
|
|
|
* @param {object} context - context to render against
|
2017-03-28 22:45:23 +00:00
|
|
|
* @param blacklistPathRegex - don't render these paths
|
2017-07-11 01:05:54 +00:00
|
|
|
* @param errorMode - how to handle errors
|
|
|
|
* @param name - name to include in error message
|
2017-02-20 18:32:27 +00:00
|
|
|
* @return {Promise.<*>}
|
|
|
|
*/
|
2018-06-25 17:42:50 +00:00
|
|
|
export async function render<T>(
|
2017-07-20 01:55:40 +00:00
|
|
|
obj: T,
|
|
|
|
context: Object = {},
|
|
|
|
blacklistPathRegex: RegExp | null = null,
|
|
|
|
errorMode: string = THROW_ON_ERROR,
|
|
|
|
name: string = ''
|
|
|
|
): Promise<T> {
|
2017-05-15 20:55:05 +00:00
|
|
|
// Make a deep copy so no one gets mad :)
|
|
|
|
const newObj = clone(obj);
|
2016-09-03 04:32:45 +00:00
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
async function next(
|
|
|
|
x: any,
|
|
|
|
path: string,
|
|
|
|
first: boolean = false
|
|
|
|
): Promise<any> {
|
2017-03-28 22:45:23 +00:00
|
|
|
if (blacklistPathRegex && path.match(blacklistPathRegex)) {
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2017-05-15 20:55:05 +00:00
|
|
|
const asStr = Object.prototype.toString.call(x);
|
|
|
|
|
2017-02-20 18:32:27 +00:00
|
|
|
// Leave these types alone
|
|
|
|
if (
|
2017-05-15 20:55:05 +00:00
|
|
|
asStr === '[object Date]' ||
|
|
|
|
asStr === '[object RegExp]' ||
|
|
|
|
asStr === '[object Error]' ||
|
|
|
|
asStr === '[object Boolean]' ||
|
|
|
|
asStr === '[object Number]' ||
|
|
|
|
asStr === '[object Null]' ||
|
|
|
|
asStr === '[object Undefined]'
|
2017-02-20 18:32:27 +00:00
|
|
|
) {
|
|
|
|
// Do nothing to these types
|
2017-07-20 01:55:40 +00:00
|
|
|
} else if (typeof x === 'string') {
|
2017-02-20 18:32:27 +00:00
|
|
|
try {
|
2018-06-25 17:42:50 +00:00
|
|
|
x = await templating.render(x, { context, path });
|
2017-05-15 20:55:05 +00:00
|
|
|
|
|
|
|
// If the variable outputs a tag, render it again. This is a common use
|
|
|
|
// case for environment variables:
|
|
|
|
// {{ foo }} => {% uuid 'v4' %} => dd265685-16a3-4d76-a59c-e8264c16835a
|
|
|
|
if (x.includes('{%')) {
|
2018-06-25 17:42:50 +00:00
|
|
|
x = await templating.render(x, { context, path });
|
2017-05-15 20:55:05 +00:00
|
|
|
}
|
2017-02-20 18:32:27 +00:00
|
|
|
} catch (err) {
|
2017-07-11 01:05:54 +00:00
|
|
|
if (errorMode !== KEEP_ON_ERROR) {
|
|
|
|
throw err;
|
|
|
|
}
|
2017-02-20 18:32:27 +00:00
|
|
|
}
|
|
|
|
} else if (Array.isArray(x)) {
|
|
|
|
for (let i = 0; i < x.length; i++) {
|
2017-03-28 22:45:23 +00:00
|
|
|
x[i] = await next(x[i], `${path}[${i}]`);
|
2017-02-20 18:32:27 +00:00
|
|
|
}
|
2017-07-20 01:55:40 +00:00
|
|
|
} else if (typeof x === 'object' && x !== null) {
|
2017-03-28 22:45:23 +00:00
|
|
|
// Don't even try rendering disabled objects
|
2017-05-15 20:55:05 +00:00
|
|
|
// Note, this logic probably shouldn't be here, but w/e for now
|
2017-03-28 22:45:23 +00:00
|
|
|
if (x.disabled) {
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2017-02-20 18:32:27 +00:00
|
|
|
const keys = Object.keys(x);
|
|
|
|
for (const key of keys) {
|
2017-12-21 14:01:51 +00:00
|
|
|
if (first && key.indexOf('_') === 0) {
|
|
|
|
x[key] = await next(x[key], path);
|
|
|
|
} else {
|
|
|
|
const pathPrefix = path ? path + '.' : '';
|
|
|
|
x[key] = await next(x[key], `${pathPrefix}${key}`);
|
|
|
|
}
|
2016-09-03 04:32:45 +00:00
|
|
|
}
|
2016-11-29 20:55:31 +00:00
|
|
|
}
|
2016-09-03 04:32:45 +00:00
|
|
|
|
2017-02-20 18:32:27 +00:00
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2017-12-21 14:01:51 +00:00
|
|
|
return next(newObj, name, true);
|
2016-10-02 20:57:00 +00:00
|
|
|
}
|
2016-08-15 22:31:30 +00:00
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
export async function getRenderContext(
|
2017-07-20 01:55:40 +00:00
|
|
|
request: Request,
|
|
|
|
environmentId: string,
|
2017-12-21 14:01:51 +00:00
|
|
|
ancestors: Array<BaseModel> | null = null,
|
|
|
|
purpose: string | null = null
|
2017-07-20 01:55:40 +00:00
|
|
|
): Promise<Object> {
|
2017-02-13 08:12:02 +00:00
|
|
|
if (!ancestors) {
|
2017-04-21 04:30:52 +00:00
|
|
|
ancestors = await db.withAncestors(request, [
|
2017-11-10 10:50:39 +00:00
|
|
|
models.request.type,
|
2017-04-21 04:30:52 +00:00
|
|
|
models.requestGroup.type,
|
|
|
|
models.workspace.type
|
|
|
|
]);
|
2017-02-13 08:12:02 +00:00
|
|
|
}
|
2016-10-02 20:57:00 +00:00
|
|
|
|
2017-02-13 08:12:02 +00:00
|
|
|
const workspace = ancestors.find(doc => doc.type === models.workspace.type);
|
2017-11-10 10:50:39 +00:00
|
|
|
if (!workspace) {
|
|
|
|
throw new Error('Failed to render. Could not find workspace');
|
|
|
|
}
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
const rootEnvironment = await models.environment.getOrCreateForWorkspaceId(
|
|
|
|
workspace ? workspace._id : 'n/a'
|
|
|
|
);
|
2016-11-10 01:15:27 +00:00
|
|
|
const subEnvironment = await models.environment.getById(environmentId);
|
2016-10-02 20:57:00 +00:00
|
|
|
|
2017-07-11 01:05:54 +00:00
|
|
|
// Add meta data helper function
|
|
|
|
const baseContext = {};
|
|
|
|
baseContext.getMeta = () => ({
|
2018-06-25 19:58:03 +00:00
|
|
|
requestId: request ? request._id : null,
|
2017-07-20 01:55:40 +00:00
|
|
|
workspaceId: workspace ? workspace._id : 'n/a'
|
2017-06-09 01:10:12 +00:00
|
|
|
});
|
|
|
|
|
2017-12-21 14:01:51 +00:00
|
|
|
baseContext.getPurpose = () => purpose;
|
|
|
|
|
2017-07-11 01:05:54 +00:00
|
|
|
// Generate the context we need to render
|
2018-04-19 19:54:19 +00:00
|
|
|
return buildRenderContext(
|
2017-07-11 01:05:54 +00:00
|
|
|
ancestors,
|
|
|
|
rootEnvironment,
|
|
|
|
subEnvironment,
|
|
|
|
baseContext
|
|
|
|
);
|
2017-02-13 08:12:02 +00:00
|
|
|
}
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
export async function getRenderedRequestAndContext(
|
2017-07-20 01:55:40 +00:00
|
|
|
request: Request,
|
2017-12-21 14:01:51 +00:00
|
|
|
environmentId: string,
|
|
|
|
purpose?: string
|
2018-06-25 17:42:50 +00:00
|
|
|
): Promise<{ request: RenderedRequest, context: Object }> {
|
2017-04-21 04:30:52 +00:00
|
|
|
const ancestors = await db.withAncestors(request, [
|
2017-11-10 10:50:39 +00:00
|
|
|
models.request.type,
|
2017-04-21 04:30:52 +00:00
|
|
|
models.requestGroup.type,
|
|
|
|
models.workspace.type
|
|
|
|
]);
|
2017-02-13 08:12:02 +00:00
|
|
|
const workspace = ancestors.find(doc => doc.type === models.workspace.type);
|
2017-08-22 22:30:57 +00:00
|
|
|
const parentId = workspace ? workspace._id : 'n/a';
|
|
|
|
const cookieJar = await models.cookieJar.getOrCreateForParentId(parentId);
|
2017-02-13 08:12:02 +00:00
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
const renderContext = await getRenderContext(
|
|
|
|
request,
|
|
|
|
environmentId,
|
|
|
|
ancestors,
|
|
|
|
purpose
|
|
|
|
);
|
2016-10-02 20:57:00 +00:00
|
|
|
|
2018-06-28 03:49:40 +00:00
|
|
|
// HACK: Switch '#}' to '# }' to prevent Nunjucks from barfing
|
|
|
|
// https://github.com/getinsomnia/insomnia/issues/895
|
2018-06-28 03:43:38 +00:00
|
|
|
try {
|
|
|
|
if (request.body.text && request.body.mimeType === CONTENT_TYPE_GRAPHQL) {
|
|
|
|
const o = JSON.parse(request.body.text);
|
|
|
|
o.query = o.query.replace(/#}/g, '# }');
|
|
|
|
request.body.text = JSON.stringify(o);
|
|
|
|
}
|
|
|
|
} catch (err) {}
|
|
|
|
|
2016-10-02 20:57:00 +00:00
|
|
|
// Render all request properties
|
2017-12-21 14:01:51 +00:00
|
|
|
const renderResult = await render(
|
2018-06-25 17:42:50 +00:00
|
|
|
{ _request: request, _cookieJar: cookieJar },
|
2017-03-28 22:45:23 +00:00
|
|
|
renderContext,
|
|
|
|
request.settingDisableRenderRequestBody ? /^body.*/ : null
|
|
|
|
);
|
2016-10-02 20:57:00 +00:00
|
|
|
|
2017-12-21 14:01:51 +00:00
|
|
|
const renderedRequest = renderResult._request;
|
|
|
|
const renderedCookieJar = renderResult._cookieJar;
|
2017-08-18 21:17:18 +00:00
|
|
|
|
2016-11-22 19:42:10 +00:00
|
|
|
// Remove disabled params
|
2018-06-25 17:42:50 +00:00
|
|
|
renderedRequest.parameters = renderedRequest.parameters.filter(
|
|
|
|
p => !p.disabled
|
|
|
|
);
|
2016-11-22 19:42:10 +00:00
|
|
|
|
|
|
|
// Remove disabled headers
|
|
|
|
renderedRequest.headers = renderedRequest.headers.filter(p => !p.disabled);
|
|
|
|
|
|
|
|
// Remove disabled body params
|
|
|
|
if (renderedRequest.body && Array.isArray(renderedRequest.body.params)) {
|
2018-06-25 17:42:50 +00:00
|
|
|
renderedRequest.body.params = renderedRequest.body.params.filter(
|
|
|
|
p => !p.disabled
|
|
|
|
);
|
2016-11-22 19:42:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Remove disabled authentication
|
2018-06-25 17:42:50 +00:00
|
|
|
if (
|
|
|
|
renderedRequest.authentication &&
|
|
|
|
renderedRequest.authentication.disabled
|
|
|
|
) {
|
2017-03-03 20:09:08 +00:00
|
|
|
renderedRequest.authentication = {};
|
2016-11-22 19:42:10 +00:00
|
|
|
}
|
|
|
|
|
2016-10-02 20:57:00 +00:00
|
|
|
// Default the proto if it doesn't exist
|
|
|
|
renderedRequest.url = setDefaultProtocol(renderedRequest.url);
|
|
|
|
|
2017-07-20 01:55:40 +00:00
|
|
|
return {
|
2017-12-21 14:01:51 +00:00
|
|
|
context: renderContext,
|
|
|
|
request: {
|
|
|
|
// Add the yummy cookies
|
|
|
|
// TODO: Eventually get rid of RenderedRequest type and put these elsewhere
|
|
|
|
cookieJar: renderedCookieJar,
|
|
|
|
cookies: [],
|
2018-03-06 03:15:09 +00:00
|
|
|
isPrivate: false,
|
2017-12-21 14:01:51 +00:00
|
|
|
|
|
|
|
// NOTE: Flow doesn't like Object.assign, so we have to do each property manually
|
|
|
|
// for now to convert Request to RenderedRequest.
|
|
|
|
_id: renderedRequest._id,
|
|
|
|
authentication: renderedRequest.authentication,
|
|
|
|
body: renderedRequest.body,
|
|
|
|
created: renderedRequest.created,
|
|
|
|
modified: renderedRequest.modified,
|
|
|
|
description: renderedRequest.description,
|
|
|
|
headers: renderedRequest.headers,
|
|
|
|
metaSortKey: renderedRequest.metaSortKey,
|
|
|
|
method: renderedRequest.method,
|
|
|
|
name: renderedRequest.name,
|
|
|
|
parameters: renderedRequest.parameters,
|
|
|
|
parentId: renderedRequest.parentId,
|
2018-06-25 17:42:50 +00:00
|
|
|
settingDisableRenderRequestBody:
|
|
|
|
renderedRequest.settingDisableRenderRequestBody,
|
2017-12-21 14:01:51 +00:00
|
|
|
settingEncodeUrl: renderedRequest.settingEncodeUrl,
|
|
|
|
settingSendCookies: renderedRequest.settingSendCookies,
|
|
|
|
settingStoreCookies: renderedRequest.settingStoreCookies,
|
2018-03-26 17:43:42 +00:00
|
|
|
settingRebuildPath: renderedRequest.settingRebuildPath,
|
2018-06-06 20:48:14 +00:00
|
|
|
settingMaxTimelineDataSize: renderedRequest.settingMaxTimelineDataSize,
|
2017-12-21 14:01:51 +00:00
|
|
|
type: renderedRequest.type,
|
|
|
|
url: renderedRequest.url
|
|
|
|
}
|
2017-07-20 01:55:40 +00:00
|
|
|
};
|
2016-10-02 20:57:00 +00:00
|
|
|
}
|
2017-11-27 15:52:35 +00:00
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
export async function getRenderedRequest(
|
2017-12-21 14:01:51 +00:00
|
|
|
request: Request,
|
|
|
|
environmentId: string,
|
|
|
|
purpose?: string
|
|
|
|
): Promise<RenderedRequest> {
|
2018-06-25 17:42:50 +00:00
|
|
|
const result = await getRenderedRequestAndContext(
|
|
|
|
request,
|
|
|
|
environmentId,
|
|
|
|
purpose
|
|
|
|
);
|
2017-12-21 14:01:51 +00:00
|
|
|
return result.request;
|
|
|
|
}
|
|
|
|
|
2017-11-27 15:52:35 +00:00
|
|
|
/**
|
|
|
|
* Sort the keys that may have Nunjucks last, so that other keys get
|
|
|
|
* defined first. Very important if env variables defined in same obj
|
|
|
|
* (eg. {"foo": "{{ bar }}", "bar": "Hello World!"})
|
|
|
|
*
|
|
|
|
* @param v
|
|
|
|
* @returns {number}
|
|
|
|
*/
|
2018-06-25 17:42:50 +00:00
|
|
|
function _nunjucksSortValue(v) {
|
2017-11-27 15:52:35 +00:00
|
|
|
if (v && v.match && v.match(/({%)/)) {
|
|
|
|
return 3;
|
|
|
|
} else if (v && v.match && v.match(/({{)/)) {
|
|
|
|
return 2;
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-25 17:42:50 +00:00
|
|
|
function _getOrderedEnvironmentKeys(finalRenderContext: Object): Array<string> {
|
2017-11-27 15:52:35 +00:00
|
|
|
return Object.keys(finalRenderContext).sort((k1, k2) => {
|
|
|
|
const k1Sort = _nunjucksSortValue(finalRenderContext[k1]);
|
|
|
|
const k2Sort = _nunjucksSortValue(finalRenderContext[k2]);
|
|
|
|
return k1Sort - k2Sort;
|
|
|
|
});
|
|
|
|
}
|