diff options
author | Josh Haberman <jhaberman@gmail.com> | 2016-06-16 14:45:42 -0700 |
---|---|---|
committer | Feng Xiao <xfxyjwf@gmail.com> | 2016-06-17 11:25:02 -0700 |
commit | fd17c94259d9c1b611080e1fdd0525c3eee0d5bb (patch) | |
tree | 895cf9895307ee83b8863fd9bd42daf540dcb7d0 /src/google | |
parent | a0f490370c49106cb68b704a3dd12ea6d0de83d8 (diff) | |
download | protobuf-fd17c94259d9c1b611080e1fdd0525c3eee0d5bb.tar.gz protobuf-fd17c94259d9c1b611080e1fdd0525c3eee0d5bb.tar.bz2 protobuf-fd17c94259d9c1b611080e1fdd0525c3eee0d5bb.zip |
Bugfix: base the require logic on the file being required.
Diffstat (limited to 'src/google')
-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 5d1ba598..17d50987 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 "./"; } @@ -2845,7 +2845,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)); } } |