New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hmpo-template-mixins

Package Overview
Dependencies
Maintainers
3
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hmpo-template-mixins - npm Package Compare versions

Comparing version 0.2.2 to 0.3.0

7

lib/template-mixins.js

@@ -329,2 +329,9 @@ 'use strict';

res.locals.url = function () {
return function (url) {
url = Hogan.compile(url).render(this);
return path.resolve(req.baseUrl, url);
};
};
next();

@@ -331,0 +338,0 @@ };

2

package.json
{
"name": "hmpo-template-mixins",
"version": "0.2.2",
"version": "0.3.0",
"description": "A middleware that exposes a series of Mustache mixins on res.locals to ease usage of forms, translations, and some general needs.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -293,4 +293,32 @@ var mixins = require('../lib/template-mixins');

describe('url', function () {
beforeEach(function () {
middleware = mixins(translate, {});
});
it('prepends the baseUrl to relative paths', function () {
req.baseUrl = '/base';
middleware(req, res, next);
res.locals.url().call(res.locals, './path').should.equal('/base/path');
res.locals.url().call(res.locals, 'path').should.equal('/base/path');
});
it('does not prepend the baseUrl to absolute paths', function () {
req.baseUrl = '/base';
middleware(req, res, next);
res.locals.url().call(res.locals, '/path').should.equal('/path');
});
it('supports urls defined in template placeholders', function () {
req.baseUrl = '/base';
res.locals.href = './link'
middleware(req, res, next);
res.locals.url().call(res.locals, '{{href}}').should.equal('/base/link');
});
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc