Skip to content

Commit

Permalink
When a path module ends in a slash, it is really the same as when you…
Browse files Browse the repository at this point in the history
… don't have the slash in there. E.g. require('modules/') and require('./') really mean require('modles') and require('.'). This will allow for a file inside of a folder to find folder/index.js without attempting to request folder/.js and folder//index.js using require('./')
  • Loading branch information
marcuswestin committed Feb 20, 2011
1 parent 00d47b7 commit cb6e3b9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion require.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ if (typeof require == 'undefined') (function() {
getDir = function(path) { return splitPathRegex.exec(path)[1] || '' }

var slashDotSlashRegex = /\/\.\//g,
doubleSlashRegex = /\/\//g
doubleSlashRegex = /\/\//g,
endInSlashRegex = /\/$/g
var resolvePath = function(base, path) {
if (path[0] == '/') { path = require._root + path }
else { path = base + path }
var pathParts = path
.replace(doubleSlashRegex, '/')
.replace(slashDotSlashRegex, '/')
.replace(endInSlashRegex, '')
.split('/')

var i=0
Expand Down

0 comments on commit cb6e3b9

Please sign in to comment.