Comparing version 2.1.0 to 2.2.0
22
index.js
@@ -24,4 +24,3 @@ 'use strict'; | ||
baseUrl: '', | ||
sort: 'url', | ||
cleanUrls: true | ||
sort: 'url' | ||
}, options || {}); | ||
@@ -46,5 +45,4 @@ | ||
} | ||
var fileUrl = url(file); | ||
file.data = extend({ url: fileUrl }, file.data || {}); | ||
buffer[fileUrl] = file; | ||
file.data = extend({ url: cleanUrl(file), dirtyUrl: url(file) }, file.data || {}); | ||
buffer[cleanUrl(file)] = file; | ||
} | ||
@@ -129,4 +127,3 @@ | ||
/** | ||
* Generate a URL for the file, adding base url and trimming any index.html | ||
* or index.htm | ||
* Generate the URL for the file | ||
* | ||
@@ -136,6 +133,15 @@ * @param {object} file | ||
function url(file) { | ||
return options.baseUrl + (options.cleanUrls ? file.relative.replace(/index\..+$/, '') : file.relative); | ||
return options.baseUrl + file.relative; | ||
} | ||
/** | ||
* Generate a clean URL for the file, without any trailing index.* | ||
* | ||
* @param {object} file | ||
*/ | ||
function cleanUrl(file) { | ||
return url(file).replace(/index\..+$/, ''); | ||
} | ||
/** | ||
* Sort an array of files on `options.sort` property of `data` | ||
@@ -142,0 +148,0 @@ * |
{ | ||
"name": "gulp-ssg", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/paulwib/gulp-ssg", |
@@ -26,3 +26,4 @@ [gulp][]-ssg [![NPM version][npm-image]][npm-url] [![Dependency Status][depstat-image]][depstat-url] [![Build Status][travis-image]][travis-url] | ||
* `file.data.url` - A URL, which is the `file.relative` with a slash prepended and any trailing `index.html` removed | ||
* `file.data.url` - A URL, which is the `file.relative` with a slash prepended and any trailing `index.*` removed | ||
* `file.data.dirtyUrl` - As above, but without trailing `index.*` removed | ||
* `file.data.root` - A pointer to the root file | ||
@@ -100,7 +101,3 @@ * `file.data.parent` - A pointer to the parent file | ||
### cleanUrls `bool` | ||
Whether or not to remove `index.*` from URLs, defaults to true. Switch to false to have full path including any `index.*`. | ||
[gulp]:http://gulpjs.com | ||
@@ -107,0 +104,0 @@ [gulp-data]:https://github.com/colynb/gulp-data |
@@ -360,7 +360,4 @@ 'use strict'; | ||
it('should support NOT removing index.html from urls', function(done) { | ||
var options = { | ||
cleanUrls: false | ||
}; | ||
var stream = ssg(options); | ||
it('should store dirty URL with any index.* intact', function(done) { | ||
var stream = ssg(); | ||
var h = mockFile('test/index.md'); | ||
@@ -372,6 +369,6 @@ var p1 = mockFile('test/hello.xhtml'); | ||
stream.on('end', function() { | ||
expect(h.data.url).to.equal('/index.md'); | ||
expect(p1.data.url).to.equal('/hello.xhtml'); | ||
expect(p2.data.url).to.equal('/foo/index.htm'); | ||
expect(p2_1.data.url).to.equal('/foo/bar.xml'); | ||
expect(h.data.dirtyUrl).to.equal('/index.md'); | ||
expect(p1.data.dirtyUrl).to.equal('/hello.xhtml'); | ||
expect(p2.data.dirtyUrl).to.equal('/foo/index.htm'); | ||
expect(p2_1.data.dirtyUrl).to.equal('/foo/bar.xml'); | ||
done(); | ||
@@ -378,0 +375,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
474
23682
112