Skip to content

Commit

Permalink
get layout instance without /meta
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonpecora committed Jul 5, 2018
1 parent 451d887 commit fa80274
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/getLayoutInstance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const isUriStringCheck = require('../strCheck');
*/
module.exports = function (uri) {
isUriStringCheck.strCheck(uri);
const result = /\/_layouts\/.+?\/instances\/([^\.@]+)/.exec(uri);
const result = /\/_layouts\/.+?\/instances\/([^\.\/@]+)/.exec(uri);

return result && result[1];
};
6 changes: 5 additions & 1 deletion lib/getLayoutInstance/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ describe('getLayoutInstance', () => {
});

it('gets instance from full uri', function () {
expect(fn('nymag.com/press/_layouts/base/instances/foobarbaz@published')).to.equal('foobarbaz');
expect(fn('domain.com/sitepath/_layouts/base/instances/foobarbaz@published')).to.equal('foobarbaz');
});

it('gets instance without meta', function () {
expect(fn('domain.com/_layouts/foobar/instances/baz/meta')).to.equal('baz');
});

it('CANNOT get instance from default uri', function () {
Expand Down

0 comments on commit fa80274

Please sign in to comment.