Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
request(method: string, path: string, body?: {}, options?: {}, responseOutput?: { response: Response}): Promise {
let requestOptions = extend(true, {headers: {}}, this.defaults || {}, options || {}, {method, body});
let contentType = requestOptions.headers['Content-Type'] || requestOptions.headers['content-type'];
// if body is object, stringify to json or urlencoded depending on content-type
if (typeof body === 'object' && body !== null && contentType) {
requestOptions.body = (/^application\/(.+\+)?json/).test(contentType.toLowerCase())
? JSON.stringify(body)
: buildQueryString(body);
}
return this.client.fetch(path, requestOptions).then((response: Response) => {
if (response.status >= 200 && response.status < 400) {
if (responseOutput) {
responseOutput.response = response;
}
return response.json().catch(() => null);
}
throw response;
});
}
} else {
output += '/';
output += segmentValue;
}
}
if (output.charAt(0) !== '/') {
output = '/' + output;
}
// remove params used in the path and add the rest to the querystring
for (let param in consumed) {
delete routeParams[param];
}
let queryString = buildQueryString(routeParams);
output += queryString ? `?${queryString}` : '';
return output;
}
function buildFullUrl(message) {
let url;
let qs;
// Message URL starts with / - as absolute URL
if (message.url && message.url[0] === '/') {
url = message.url;
} else {
url = join(message.baseUrl, message.url);
}
if (message.params) {
qs = buildQueryString(message.params);
url = qs ? `${url}?${qs}` : url;
}
return url;
}
TemplatingRouteLoader.prototype.loadRoute = function loadRoute(router, config) {
var childContainer = router.container.createChild();
var viewModel = void 0;
if (config.moduleId === null) {
viewModel = EmptyClass;
} else if (/\.html/i.test(config.moduleId)) {
viewModel = createDynamicClass(config.moduleId);
} else {
viewModel = relativeToFile(config.moduleId, Origin.get(router.container.viewModel.constructor).moduleId);
}
var instruction = {
viewModel: viewModel,
childContainer: childContainer,
view: config.view || config.viewStrategy,
router: router
};
childContainer.registerSingleton(RouterViewLocator);
childContainer.getChildRouter = function () {
var childRouter = void 0;
childContainer.registerHandler(Router, function (c) {
return childRouter || (childRouter = router.createChild(childContainer));
buildFullUrl() {
let absoluteUrl = /^([a-z][a-z0-9+\-.]*:)?\/\//i;
let url = absoluteUrl.test(this.url) ? this.url : join(this.baseUrl, this.url);
if (this.params) {
let qs = buildQueryString(this.params, this.traditional);
url = qs ? url + (this.url.indexOf('?') < 0 ? '?' : '&') + qs : url;
}
return url;
}
};
buildFullUrl(): string {
let absoluteUrl = /^([a-z][a-z0-9+\-.]*:)?\/\//i;
let url = absoluteUrl.test(this.url) ? this.url : join(this.baseUrl, this.url);
if (this.params) {
let qs = buildQueryString(this.params);
url = qs ? url + (this.url.indexOf('?') < 0 ? '?' : '&') + qs : url;
}
return url;
}
}
buildFullUrl(): string {
let absoluteUrl = /^([a-z][a-z0-9+\-.]*:)?\/\//i;
let url = absoluteUrl.test(this.url) ? this.url : join(this.baseUrl, this.url);
if (this.params) {
let qs = buildQueryString(this.params, this.traditional);
url = qs ? url + (this.url.indexOf('?') < 0 ? '?' : '&') + qs : url;
}
return url;
}
}
buildFullUrl(): string {
let absoluteUrl = /^([a-z][a-z0-9+\-.]*:)?\/\//i;
let url = absoluteUrl.test(this.url) ? this.url : join(this.baseUrl, this.url);
if (this.params) {
let qs = buildQueryString(this.params);
url = qs ? url + (this.url.indexOf('?') < 0 ? '?' : '&') + qs : url;
}
return url;
}
}
makeRelativeTo(file) {
if (this.absolutePath === null) {
this.absolutePath = relativeToFile(this.path, file);
}
}
};
return css.replace(cssUrlMatcher, function (match, p1) {
var quote = p1.charAt(0);
if (quote === '\'' || quote === '"') {
p1 = p1.substr(1, p1.length - 2);
}
return 'url(\'' + relativeToFile(p1, address) + '\')';
});
}