Skip to content

Instantly share code, notes, and snippets.

@gdiaz
Created October 9, 2012 15:21
Show Gist options
  • Save gdiaz/3859484 to your computer and use it in GitHub Desktop.
Save gdiaz/3859484 to your computer and use it in GitHub Desktop.
Requirejs problem
nameToUrl: function (moduleName, ext) {
var paths, pkgs, pkg, pkgPath, syms, i, parentModule, url,
parentPath;
//If a colon is in the URL, it indicates a protocol is used and it is just
//an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?)
//or ends with .js, then assume the user meant to use an url and not a module id.
//The slash is important for protocol-less URLs as well as full paths.
if (req.jsExtRegExp.test(moduleName)) {
//Just a plain path, not module name lookup, so just return it.
//Add extension if it is included. This is a bit wonky, only non-.js things pass
//an extension, this method probably needs to be reworked.
url = moduleName + (ext || '');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment