Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"hexo-fs": "^2.0.0",
"hexo-i18n": "^1.0.0",
"hexo-log": "^1.0.0",
"hexo-util": "^1.4.0",
"hexo-util": "^1.5.0",
"js-yaml": "^3.12.0",
"lodash": "^4.17.11",
"micromatch": "^4.0.2",
Expand Down
3 changes: 2 additions & 1 deletion test/scripts/helpers/open_graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const moment = require('moment');
const cheerio = require('cheerio');
const { encodeURL } = require('hexo-util');

describe('open_graph', () => {
const Hexo = require('../../../lib/hexo');
Expand Down Expand Up @@ -141,7 +142,7 @@ describe('open_graph', () => {

const result = openGraph.call(ctx);

result.should.contain(meta({property: 'og:url', content: 'https://xn--fo-9ja.com/b%C3%A1r'}));
result.should.contain(meta({property: 'og:url', content: encodeURL(ctx.url)}));
});

it('images - content', () => {
Expand Down
8 changes: 5 additions & 3 deletions test/scripts/hexo/hexo.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const Promise = require('bluebird');
const sinon = require('sinon');
const sep = pathFn.sep;
const testUtil = require('../../util');
const { full_url_for } = require('hexo-util');

describe('Hexo', () => {
const base_dir = pathFn.join(__dirname, 'hexo_test');
Expand Down Expand Up @@ -427,17 +428,18 @@ describe('Hexo', () => {
});

it('_generate() - should encode url', () => {
const path = 'bár';
hexo.config.url = 'http://fôo.com';

hexo.theme.setView('test.swig', '{{ url }}');

hexo.extend.generator.register('test', () => ({
path: 'bár',
path,
layout: 'test'
}));

return hexo._generate().then(() => checkStream(route.get('bár'),
'http://xn--fo-8ja.com/b%C3%A1r'));
return hexo._generate().then(() => checkStream(route.get(path),
full_url_for.call(hexo, path)));
});

it('_generate() - do nothing if it\'s generating', () => {
Expand Down
5 changes: 3 additions & 2 deletions test/scripts/models/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const sinon = require('sinon');
const Promise = require('bluebird');
const { full_url_for } = require('hexo-util');

describe('Category', () => {
const Hexo = require('../../../lib/hexo');
Expand Down Expand Up @@ -118,9 +119,9 @@ describe('Category', () => {
it('permalink - should be encoded', () => {
hexo.config.url = 'http://fôo.com';
return Category.insert({
name: 'bár'
name: ''
}).then(data => {
data.permalink.should.eql('http://xn--fo-8ja.com/' + data.path);
data.permalink.should.eql(full_url_for.call(hexo, data.path));
hexo.config.url = 'http://yoursite.com';
return Category.removeById(data._id);
});
Expand Down
6 changes: 4 additions & 2 deletions test/scripts/models/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const sinon = require('sinon');
const pathFn = require('path');
const { full_url_for } = require('hexo-util');

describe('Page', () => {
const Hexo = require('../../../lib/hexo');
Expand Down Expand Up @@ -74,11 +75,12 @@ describe('Page', () => {

it('permalink - should be encoded', () => {
hexo.config.url = 'http://fôo.com';
const path = 'bár';
return Page.insert({
source: 'foo',
path: 'bár'
path
}).then(data => {
data.permalink.should.eql('http://xn--fo-8ja.com/b%C3%A1r');
data.permalink.should.eql(full_url_for.call(hexo, data.path));
hexo.config.url = 'http://yoursite.com';
return Page.removeById(data._id);
});
Expand Down
6 changes: 4 additions & 2 deletions test/scripts/models/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const sinon = require('sinon');
const pathFn = require('path');
const Promise = require('bluebird');
const { full_url_for } = require('hexo-util');

describe('Post', () => {
const Hexo = require('../../../lib/hexo');
Expand Down Expand Up @@ -85,12 +86,13 @@ describe('Post', () => {
});

it('permalink - should be encoded', () => {
const slug = 'bár';
hexo.config.url = 'http://fôo.com';
return Post.insert({
source: 'foo.md',
slug: 'bár'
slug
}).then(data => {
data.permalink.should.eql('http://xn--fo-8ja.com/b%C3%A1r');
data.permalink.should.eql(full_url_for.call(hexo, slug));
hexo.config.url = 'http://yoursite.com';
return Post.removeById(data._id);
});
Expand Down
5 changes: 3 additions & 2 deletions test/scripts/models/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const sinon = require('sinon');
const Promise = require('bluebird');
const { full_url_for } = require('hexo-util');

describe('Tag', () => {
const Hexo = require('../../../lib/hexo');
Expand Down Expand Up @@ -103,9 +104,9 @@ describe('Tag', () => {
it('permalink - should be encoded', () => {
hexo.config.url = 'http://fôo.com';
return Tag.insert({
name: 'bár'
name: ''
}).then(data => {
data.permalink.should.eql('http://xn--fo-8ja.com/' + data.path);
data.permalink.should.eql(full_url_for.call(hexo, data.path));
hexo.config.url = 'http://yoursite.com';
return Tag.removeById(data._id);
});
Expand Down