mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
ensure that filenames do not start with an underscore (#758)
Squashed commit of the following:
commit 11da3dbe026fb0c76d619f0295a195d1f012462e
Author: Jeff Williams <jeffrey.l.williams@gmail.com>
Date: Fri Nov 7 14:42:02 2014 -0800
add test for #758
commit f3e001d549c5e0e69e50b231f375da92f3e8f688
Merge: df1f4bd d551131
Author: Jeff Williams <jeffrey.l.williams@gmail.com>
Date: Fri Nov 7 14:32:30 2014 -0800
Merge remote-tracking branch 'danorton/patch-1' into 758
commit d5511316468eb93f852c51fab5eec380bcfee4b4
Author: Daniel Norton <daniel@danielnorton.com>
Date: Wed Sep 3 17:00:49 2014 -0500
Prevent filenames beginning with underscore
A lot of related software (most notably github.io and the default configuration of jsdoc itself) ignores files with names that begin with an underscore, but the makeUniqueFilename() creates such filenames when the incoming filename is blank. This patch modifies makeUniqueFilename() to insert the ASCII letter "X" before empty filenames or filenames that begin with an underscore.
This commit is contained in:
parent
df1f4bda22
commit
8f1d892fbf
@ -42,6 +42,12 @@ function makeUniqueFilename(filename, str) {
|
||||
var key = filename.toLowerCase();
|
||||
var nonUnique = true;
|
||||
|
||||
// don't allow filenames to begin with an underscore
|
||||
if (!filename.length || filename[0] === '_') {
|
||||
filename = 'X' + filename;
|
||||
key = filename.toLowerCase();
|
||||
}
|
||||
|
||||
// append enough underscores to make the filename unique
|
||||
while (nonUnique) {
|
||||
if ( hasOwnProp.call(files, key) ) {
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
/*global afterEach, beforeEach, describe, expect, env, it, jasmine, spyOn, xdescribe */
|
||||
/*eslint quotes:0 */
|
||||
'use strict';
|
||||
|
||||
var hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
|
||||
describe("jsdoc/util/templateHelper", function() {
|
||||
var helper = require('jsdoc/util/templateHelper'),
|
||||
doclet = require('jsdoc/doclet'),
|
||||
doop = require('jsdoc/util/doop'),
|
||||
logger = require('jsdoc/util/logger'),
|
||||
resolver = require('jsdoc/tutorial/resolver'),
|
||||
taffy = require('taffydb').taffy;
|
||||
var helper = require('jsdoc/util/templateHelper');
|
||||
var doclet = require('jsdoc/doclet');
|
||||
var doop = require('jsdoc/util/doop');
|
||||
var logger = require('jsdoc/util/logger');
|
||||
var resolver = require('jsdoc/tutorial/resolver');
|
||||
var taffy = require('taffydb').taffy;
|
||||
|
||||
helper.registerLink('test', 'path/to/test.html');
|
||||
|
||||
it("should exist", function() {
|
||||
@ -202,6 +202,10 @@ describe("jsdoc/util/templateHelper", function() {
|
||||
expect(filename).toBe('a very strange __________ filename.html');
|
||||
});
|
||||
|
||||
it('should not allow a filename to start with an underscore', function() {
|
||||
expect( helper.getUniqueFilename('') ).toBe('X_.html');
|
||||
});
|
||||
|
||||
it('should not return the same filename twice', function() {
|
||||
var name = 'polymorphic';
|
||||
var filename1 = helper.getUniqueFilename(name);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user