Skip to content

Commit

Permalink
Merge pull request #88 from escorp/fix-array-options
Browse files Browse the repository at this point in the history
match options before analyzing
  • Loading branch information
ssav0 authored Apr 4, 2017
2 parents 315075a + 15a0d47 commit d5c85a3
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,20 @@ const getPattern = (decl) =>
* @returns {String|undefined}
*/
const replaceUrl = (url, dir, options, result, decl) => {
const isFunction = typeof options.url === 'function';

if (!isFunction && isUrlShouldBeIgnored(url, options)) return;

const asset = prepareAsset(url, dir, options.basePath);
const relativeToRoot = path.relative(process.cwd(), asset.absolutePath);

options = matchOptions(relativeToRoot, options);
if (!options) return;
const matchedOptions = matchOptions(relativeToRoot, options);
if (!matchedOptions) return;

const isFunction = typeof matchedOptions.url === 'function';
if (!isFunction && isUrlShouldBeIgnored(url, matchedOptions)) return;

const mode = isFunction ? 'custom' : (options.url || 'rebase');
const urlProcessor = getUrlProcessor(mode || 'rebase');
const mode = isFunction ? 'custom' : (matchedOptions.url || 'rebase');
const urlProcessor = getUrlProcessor(mode);
const warn = (message) => decl.warn(result, message);

return urlProcessor(asset, dir, options, decl, warn, result);
return urlProcessor(asset, dir, matchedOptions, decl, warn, result);
};

/**
Expand Down

0 comments on commit d5c85a3

Please sign in to comment.