Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current implementation seems to suggest
require.toUrl
should only be used to get the path of an AMD module, even though the documentation also mentions a different use :Nevertheless, this method can't be used for all kinds of paths, like relative path that don't have an extension or paths that have components after the extension (which is not uncommon for a url).
This is because
require.toUrl
determines the position of the extension by taking the last dot of a path and considering everything starting from that dot as an extension.This is very annoying, especially because this makes the behavior of
require.toUrl
different for RequireJS and the Dojo loader and results in invalid paths in RequireJS for even paths as simple and common as../resources/
.This could easily be fixed by determining the position of the extension with a regex, like this :
My pull requests contains three changes to the source code :
lastIndexOf
with this newfindExtension
function for determining the position of the extensionmoduleNamePlusExt
argument oftoUrl
topath
, to reflect that can be used in different contexttoUrl