Changeset 189439 in webkit for trunk/Source/JavaScriptCore/jsc.cpp
- Timestamp:
- Sep 5, 2015, 12:45:58 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/jsc.cpp
r189431 r189439 748 748 }; 749 749 750 struct ModuleName { 751 ModuleName(const String& moduleName); 752 753 bool startsWithRoot() const 754 { 755 return !queries.isEmpty() && queries[0].isEmpty(); 756 } 757 758 Vector<String> queries; 759 }; 760 761 ModuleName::ModuleName(const String& moduleName) 762 { 763 // A module name given from code is represented as the UNIX style path. Like, `./A/B.js`. 764 moduleName.split('/', true, queries); 765 } 766 750 767 static bool extractDirectoryName(const String& absolutePathToFile, DirectoryName& directoryName) 751 768 { … … 787 804 } 788 805 789 static String resolvePath(const DirectoryName& directoryName, const String& query)806 static String resolvePath(const DirectoryName& directoryName, const ModuleName& moduleName) 790 807 { 791 808 Vector<String> directoryPieces; 792 809 directoryName.queryName.split(pathSeparator(), false, directoryPieces); 793 810 794 Vector<String> queryPieces;795 query.split(pathSeparator(), true, queryPieces);796 797 811 // Only first '/' is recognized as the path from the root. 798 if ( !queryPieces.isEmpty() && queryPieces[0].isEmpty())812 if (moduleName.startsWithRoot()) 799 813 directoryPieces.clear(); 800 814 801 for (const auto& query : queryPieces) {815 for (const auto& query : moduleName.queries) { 802 816 if (query == String(ASCIILiteral(".."))) { 803 817 if (!directoryPieces.isEmpty()) … … 851 865 } 852 866 853 return deferred->resolve(exec, jsString(exec, resolvePath(directoryName, key.impl())));867 return deferred->resolve(exec, jsString(exec, resolvePath(directoryName, ModuleName(key.impl())))); 854 868 } 855 869
Note:
See TracChangeset
for help on using the changeset viewer.