Skip to content

Commit

Permalink
revert: PR #79 (#135)
Browse files Browse the repository at this point in the history
You need run `isUrlRequest` before run `urlToRequest`.
  • Loading branch information
evilebottnawi committed Dec 25, 2018
1 parent aca43da commit 73d350a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
15 changes: 15 additions & 0 deletions README.md
Expand Up @@ -115,6 +115,21 @@ loaderUtils.stringifyRequest(this, "\\\\network-drive\\test.js");

Converts some resource URL to a webpack module request.

> i Before call `urlToRequest` you need call `isUrlRequest` to ensure it is requestable url
```javascript
const url = "path/to/module.js";

if (loaderUtils.isUrlRequest(url)) {
// Logic for requestable url
const request = loaderUtils.urlToRequest(url);
} else {
// Logic for not requestable url
}
```

Simple example:

```javascript
const url = "path/to/module.js";
const request = loaderUtils.urlToRequest(url); // "./path/to/module.js"
Expand Down
3 changes: 0 additions & 3 deletions lib/urlToRequest.js
Expand Up @@ -41,9 +41,6 @@ function urlToRequest(url, root) {
'.'
);
}
} else if (/^(?:https?:)?\/\//.test(url)) {
// Preserve http and https urls
request = url;
} else if (/^\.\.?\//.test(url)) {
// A relative url stays
request = url;
Expand Down
3 changes: 0 additions & 3 deletions test/urlToRequest.test.js
Expand Up @@ -13,9 +13,6 @@ ExpectedError.prototype.matches = function(err) {
describe('urlToRequest()', () => {
[
// without root
[['//google.com'], '//google.com', 'should handle scheme-agnostic urls'],
[['http://google.com'], 'http://google.com', 'should handle http urls'],
[['https://google.com'], 'https://google.com', 'should handle https urls'],
[
['path/to/thing'],
'./path/to/thing',
Expand Down

0 comments on commit 73d350a

Please sign in to comment.