diff options
author | Josh Haberman <jhaberman@gmail.com> | 2016-06-16 14:45:42 -0700 |
---|---|---|
committer | Josh Haberman <jhaberman@gmail.com> | 2016-06-16 14:45:42 -0700 |
commit | 0e27112c2b737b7236ecba6ac4bfd79f6b2b1bfd (patch) | |
tree | b945f0484ce00408b9f24479bf8af788ece5ec07 /src | |
parent | 1337486755518e8df4388463ab71fdc955e5a680 (diff) | |
download | protobuf-0e27112c2b737b7236ecba6ac4bfd79f6b2b1bfd.tar.gz protobuf-0e27112c2b737b7236ecba6ac4bfd79f6b2b1bfd.tar.bz2 protobuf-0e27112c2b737b7236ecba6ac4bfd79f6b2b1bfd.zip |
Bugfix: base the require logic on the file being required.
Diffstat (limited to 'src')
-rwxr-xr-x | src/google/protobuf/compiler/js/js_generator.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/google/protobuf/compiler/js/js_generator.cc b/src/google/protobuf/compiler/js/js_generator.cc index b39b0e8c..8fb24bed 100755 --- a/src/google/protobuf/compiler/js/js_generator.cc +++ b/src/google/protobuf/compiler/js/js_generator.cc @@ -159,8 +159,8 @@ string GetJSFilename(const string& filename) { // Given a filename like foo/bar/baz.proto, returns the root directory // path ../../ -string GetRootPath(const string& filename) { - if (filename.find("google/protobuf") == 0) { +string GetRootPath(const string& from_filename, const string& to_filename) { + if (to_filename.find("google/protobuf") == 0) { // Well-known types (.proto files in the google/protobuf directory) are // assumed to come from the 'google-protobuf' npm package. We may want to // generalize this exception later by letting others put generated code in @@ -168,7 +168,7 @@ string GetRootPath(const string& filename) { return "google-protobuf/"; } - size_t slashes = std::count(filename.begin(), filename.end(), '/'); + size_t slashes = std::count(from_filename.begin(), from_filename.end(), '/'); if (slashes == 0) { return "./"; } @@ -2846,7 +2846,7 @@ void Generator::GenerateFile(const GeneratorOptions& options, printer->Print( "var $alias$ = require('$file$');\n", "alias", ModuleAlias(name), - "file", GetRootPath(file->name()) + GetJSFilename(name)); + "file", GetRootPath(file->name(), name) + GetJSFilename(name)); } } |