-
-
Notifications
You must be signed in to change notification settings - Fork 105
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
fix remote-path normalization (#127) #128
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,25 @@ | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
var urlRegex = require('url-regex'); | ||
var normalizeUrl = require('normalize-url'); | ||
var removeTrailingSep = require('remove-trailing-separator'); | ||
|
||
function normalize(str) { | ||
return str === '' ? str : path.normalize(str); | ||
if (str === '') { | ||
return str; | ||
} | ||
|
||
if (urlRegex().test(str) && !/^www\./.test(str)) { | ||
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.
|
||
return normalizeUrl(str, { | ||
normalizeProtocol: false, | ||
stripFragment: false, | ||
stripWWW: false, | ||
removeTrailingSlash: false, | ||
}); | ||
} | ||
|
||
return removeTrailingSep(path.normalize(str)); | ||
} | ||
|
||
module.exports = normalize; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,9 @@ | |
"cloneable-readable": "^1.0.0", | ||
"is-stream": "^1.1.0", | ||
"remove-trailing-separator": "^1.0.1", | ||
"replace-ext": "^1.0.0" | ||
"replace-ext": "^1.0.0", | ||
"normalize-url": "1.6.1", | ||
"url-regex": "3.2.0" | ||
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. Fix versions for |
||
}, | ||
"devDependencies": { | ||
"eslint": "^1.7.3", | ||
|
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.
moved to normalize to allow remote paths with trailing slash