Skip to content
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

src 路径为空时,会替换为 js 文件路径 #22

Open
animabear opened this issue Dec 27, 2017 · 0 comments
Open

src 路径为空时,会替换为 js 文件路径 #22

animabear opened this issue Dec 27, 2017 · 0 comments

Comments

@animabear
Copy link

当 html 中存在 src 为空的情况(这不是一个好习惯,为空建议不写):

page/home/index.html

<audio src=""></audio>

如果 page/home/index.js 存在,src 会被替换为:

<audio src="/pathto/page/home/index.js"></audio>

排查了下,这个地方需要判断下:

lookup.js

function findResource(name, filepath, extList) {
  // 这里需要判断下非空
  if (name === '') {
    return null;
  }
  var candidates = [name, path.join(name, 'index')];
  var baseName = path.basename(name);
  if (baseName && baseName !== '.' && baseName !== '..') {
    candidates.push(path.join(name, baseName));
  }
  var info = null;

  candidates.every(function(candidate) {
    info = fis.uri(candidate, filepath);

    for (var i = 0, len = extList.length; i < len && !info.file; i++) {
      info = fis.uri(candidate + extList[i], filepath);
    }

    if (info && info.file) {
      return false;
    }

    return true;
  });

  return info;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant