-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature rewrite-urls #3041
Closed
Closed
Feature rewrite-urls #3041
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cb4a577
Rename relativeUrls option to rewriteUrls
jhnns b95c294
Refactor contexts.js
jhnns 99df16a
Add missing tests for url rewriting
jhnns e80a91d
Rename rewrite-urls option value to explicit-relative
jhnns bfc7812
Add missing tests for url rewriting
jhnns 5ede205
Merge remote-tracking branch 'upstream/master' into feature/rewrite-urls
jhnns c2eea6b
Refactor rewrite urls options
jhnns 78b5254
Re-add tests for deprecated relative-urls option
jhnns 2e73a02
Improve tests
jhnns 2a4dfec
Fix typo in unknown argument warning
jhnns e0b7a6b
Revert old tests to deprecated relativeUrls option again
jhnns File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ var copyFromOriginal = function copyFromOriginal(original, destination, properti | |
var parseCopyProperties = [ | ||
// options | ||
'paths', // option - unmodified - paths to search for imports on | ||
'relativeUrls', // option - whether to adjust URL's to be relative | ||
'rewriteUrls', // option - whether to adjust URL's to be relative | ||
'rootpath', // option - rootpath to append to URL's | ||
'strictImports', // option - | ||
'insecure', // option - whether to allow imports from insecure ssl hosts | ||
|
@@ -50,7 +50,8 @@ var evalCopyProperties = [ | |
'urlArgs', // whether to add args into url tokens | ||
'javascriptEnabled', // option - whether Inline JavaScript is enabled. if undefined, defaults to false | ||
'pluginManager', // Used as the plugin manager for the session | ||
'importantScope' // used to bubble up !important statements | ||
'importantScope', // used to bubble up !important statements | ||
'rewriteUrls' // option - whether to adjust URL's to be relative | ||
]; | ||
|
||
contexts.Eval = function(options, frames) { | ||
|
@@ -97,17 +98,36 @@ contexts.Eval.prototype.isMathOn = function () { | |
return this.strictMath ? (this.parensStack && this.parensStack.length) : true; | ||
}; | ||
|
||
contexts.Eval.prototype.isPathRelative = function (path) { | ||
return !/^(?:[a-z-]+:|\/|#)/i.test(path); | ||
contexts.Eval.prototype.pathRequiresRewrite = function (path) { | ||
var isRelative = this.rewriteUrls === 'local' ? isPathLocalRelative : isPathRelative; | ||
|
||
return isRelative(path); | ||
}; | ||
|
||
contexts.Eval.prototype.normalizePath = function( path ) { | ||
contexts.Eval.prototype.rewritePath = function (path, rootpath) { | ||
var newPath; | ||
|
||
rootpath = rootpath || ''; | ||
newPath = this.normalizePath(rootpath + path); | ||
|
||
// If a path was explicit relative and the rootpath was not an absolute path | ||
// we must ensure that the new path is also explicit relative. | ||
if (isPathLocalRelative(path) && | ||
isPathRelative(rootpath) && | ||
isPathLocalRelative(newPath) === false) { | ||
newPath = './' + newPath; | ||
} | ||
|
||
return newPath; | ||
}; | ||
|
||
contexts.Eval.prototype.normalizePath = function (path) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changes in |
||
var | ||
segments = path.split('/').reverse(), | ||
segment; | ||
|
||
path = []; | ||
while (segments.length !== 0 ) { | ||
while (segments.length !== 0) { | ||
segment = segments.pop(); | ||
switch ( segment ) { | ||
case '.': | ||
|
@@ -120,12 +140,20 @@ contexts.Eval.prototype.normalizePath = function( path ) { | |
} | ||
break; | ||
default: | ||
path.push( segment ); | ||
path.push(segment); | ||
break; | ||
} | ||
} | ||
|
||
return path.join('/'); | ||
}; | ||
|
||
function isPathRelative(path) { | ||
return !/^(?:[a-z-]+:|\/|#)/i.test(path); | ||
} | ||
|
||
function isPathLocalRelative(path) { | ||
return path.charAt(0) === '.'; | ||
} | ||
|
||
// todo - do the same for the toCSS ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we need to change that part. However, for me it looks like
less.Parser.fileLoader
is not used anywhere. Is that file even up-to-date?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No,
less-rhino
should have been pulled in 3.0, but I just wasn't sure. I doubt it even still works. Ideally, PR #2985 should be re-written and pulled into its own repo withless
as a dependency (as inhttps://github.com/less/less-java
), and thenless-rhino
should be removed as a sub-folder.Long and short, there aren't any active Java maintainers in the Less core team, so we really can't manage it within this repo.