Skip to content

Commit 990c565

Browse files
committed
Extract path separator as const
1 parent f14e102 commit 990c565

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

js/scripts/generate-wrappers.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ var jsIndexTemplate = compileTemplate('js_index');
4141
var pyWrapperTemplate = compileTemplate('py_wrapper');
4242
var pyTopLevelInitTemplate = compileTemplate('py_top_level_init');
4343

44+
const pathSep = /\\|\//;
45+
4446
//
4547
// Helper Functions
4648
//
@@ -94,7 +96,7 @@ function getClassConfig(className, doLog) {
9496

9597
function relativePathToPythonImportPath(relativePath) {
9698

97-
var tokens = relativePath.split(/\\|\//);
99+
var tokens = relativePath.split(pathSep);
98100
var firstToken = tokens[0];
99101
var sawFolderToken = false;
100102

@@ -710,7 +712,7 @@ _.extend(PythonWrapper.prototype, {
710712

711713
processDocsUrl: function() {
712714

713-
var refTokens = this.modulePath.split(/\\|\//);
715+
var refTokens = this.modulePath.split(pathSep);
714716

715717
// capitalize elements in url
716718
refTokens = refTokens.map(function(token) {
@@ -792,7 +794,7 @@ function createTopLevelPythonModuleFile() {
792794

793795
// convert relative path to python-style import path
794796
if (modulePath !== '.') {
795-
var importPath = '.' + modulePath.split(/\\|\//).join('.') + '.' + moduleName;
797+
var importPath = '.' + modulePath.split(pathSep).join('.') + '.' + moduleName;
796798
} else {
797799
var importPath = '.' + moduleName;
798800
}

0 commit comments

Comments
 (0)