Comparing version 1.9.0 to 1.9.1
@@ -19,3 +19,3 @@ 'use strict'; | ||
return { | ||
url: toFullyQualifiedURL(src), | ||
url: toFullyQualifiedURL(src, baseOptions), | ||
headers: Object.assign({}, defaultHeaders, baseOptions.headers) | ||
@@ -25,7 +25,8 @@ }; | ||
function toFullyQualifiedURL(urlOrPath) { | ||
function toFullyQualifiedURL(urlOrPath, baseOptions) { | ||
if(urlOrPath.indexOf('http') === 0) { | ||
return urlOrPath; | ||
} else { | ||
return url.resolve(baseUrl, urlOrPath); | ||
const base = baseOptions ? baseOptions.baseUrl || baseUrl : baseUrl; | ||
return url.resolve(base, urlOrPath); | ||
} | ||
@@ -32,0 +33,0 @@ } |
@@ -115,3 +115,3 @@ 'use strict'; | ||
function get(src, options) { | ||
src = dataProvider.toFullyQualifiedURL(src); | ||
src = dataProvider.toFullyQualifiedURL(src, options); | ||
@@ -118,0 +118,0 @@ return Promise.resolve() |
{ | ||
"name": "nodesi", | ||
"version": "1.9.0", | ||
"version": "1.9.1", | ||
"description": "ESI: the good parts in node.js", | ||
@@ -5,0 +5,0 @@ "main": "esi.js", |
@@ -80,2 +80,15 @@ [![Build Status](https://travis-ci.org/Schibsted-Tech-Polska/nodesi.svg?branch=master)](https://travis-ci.org/Schibsted-Tech-Polska/nodesi) | ||
If you'd like to adjust the baseUrl dynamically, use `req.esiOptions` object: | ||
```javascript | ||
... | ||
app.use(esiMiddleware()); | ||
app.get('/example', function(req, res) { | ||
req.esiOptions = { | ||
baseUrl: req.url | ||
}; | ||
res.render('example'); | ||
}); | ||
``` | ||
#### With base URL for relative paths: | ||
@@ -82,0 +95,0 @@ ```javascript |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18818
313
202