-
-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove
normalize-url
from deps (#623)
- Loading branch information
1 parent
71a9ce9
commit 9ae47e5
Showing
8 changed files
with
159 additions
and
4,645 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* eslint-disable */ | ||
|
||
function normalizeUrl(pathComponents) { | ||
return pathComponents | ||
.reduce(function (accumulator, item) { | ||
switch (item) { | ||
case '..': | ||
accumulator.pop(); | ||
break; | ||
case '.': | ||
break; | ||
default: | ||
accumulator.push(item); | ||
} | ||
|
||
return accumulator; | ||
}, []) | ||
.join('/'); | ||
} | ||
|
||
module.exports = function (urlString) { | ||
urlString = urlString.trim(); | ||
|
||
if (/^data:/i.test(urlString)) { | ||
return urlString; | ||
} | ||
|
||
var protocol = | ||
urlString.indexOf('//') !== -1 ? urlString.split('//')[0] + '//' : ''; | ||
var components = urlString.replace(new RegExp(protocol, 'i'), '').split('/'); | ||
var host = components[0].toLowerCase().replace(/\.$/, ''); | ||
|
||
components[0] = ''; | ||
|
||
var path = normalizeUrl(components); | ||
|
||
return protocol + host + path; | ||
}; |
Oops, something went wrong.