Permalink
Browse files

Fixes #35, allow urls without file extensions. Needs requirejs 2.1.3 …

…to fully work.
  • Loading branch information...
1 parent e753e8f commit 4d207b2f27caecd8a59f3fefde3c8a764e47727e @jrburke jrburke committed Jan 22, 2013
Showing with 26 additions and 11 deletions.
  1. +26 −11 text.js
View
37 text.js
@@ -1,5 +1,5 @@
/**
- * @license RequireJS text 2.0.3 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
+ * @license RequireJS text 2.0.4 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/requirejs/text for details
*/
@@ -83,16 +83,30 @@ define(['module'], function (module) {
* where strip is a boolean.
*/
parseName: function (name) {
- var strip = false, index = name.indexOf("."),
- modName = name.substring(0, index),
+ var modName, ext, temp,
+ strip = false,
+ index = name.indexOf("."),
+ isRelative = name.indexOf('./') === 0 ||
+ name.indexOf('../') === 0;
+
+ if (index !== -1 && (!isRelative || index > 1)) {
+ modName = name.substring(0, index);
ext = name.substring(index + 1, name.length);
+ } else {
+ modName = name;
+ }
- index = ext.indexOf("!");
+ temp = ext || modName;
+ index = temp.indexOf("!");
if (index !== -1) {
//Pull off the strip arg.
- strip = ext.substring(index + 1, ext.length);
- strip = strip === "strip";
- ext = ext.substring(0, index);
+ strip = temp.substring(index + 1) === "strip";
+ temp = temp.substring(0, index);
+ if (ext) {
+ ext = temp;
+ } else {
+ modName = temp;
+ }
}
return {
@@ -156,7 +170,8 @@ define(['module'], function (module) {
masterConfig.isBuild = config.isBuild;
var parsed = text.parseName(name),
- nonStripName = parsed.moduleName + '.' + parsed.ext,
+ nonStripName = parsed.moduleName +
+ (parsed.ext ? '.' + parsed.ext : ''),
url = req.toUrl(nonStripName),
useXhr = (masterConfig.useXhr) ||
text.useXhr;
@@ -194,11 +209,11 @@ define(['module'], function (module) {
writeFile: function (pluginName, moduleName, req, write, config) {
var parsed = text.parseName(moduleName),
- nonStripName = parsed.moduleName + '.' + parsed.ext,
+ extPart = parsed.ext ? '.' + parsed.ext : '',
+ nonStripName = parsed.moduleName + extPart,
//Use a '.js' file name so that it indicates it is a
//script that can be loaded across domains.
- fileName = req.toUrl(parsed.moduleName + '.' +
- parsed.ext) + '.js';
+ fileName = req.toUrl(parsed.moduleName + extPart) + '.js';
//Leverage own load() method to load plugin value, but only
//write out values that do not have the strip argument,

0 comments on commit 4d207b2

Please sign in to comment.