Skip to content

Commit c547aa9

Browse files
committed
Trim whitespace off of strings
1 parent 495a3be commit c547aa9

File tree

1 file changed

+7
-4
lines changed
  • lib/node_modules/@stdlib/_tools/remark/plugins/remark-img-equations-src-urls/lib

1 file changed

+7
-4
lines changed

lib/node_modules/@stdlib/_tools/remark/plugins/remark-img-equations-src-urls/lib/git.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@
2222

2323
var exec = require( 'child_process' ).execSync;
2424
var logger = require( 'debug' );
25+
var trim = require( '@stdlib/string/trim' );
2526

2627

2728
// VARIABLES //
2829

2930
var debug = logger( 'remark-img-equations-src-urls:git' );
3031

3132
// Regular expression to extract a repository slug:
32-
var RE = /(?:.+github\.com)(?:\/|:)(.+)(?:\.(?:.+)|\s*$)/;
33+
var RE = /(?:.+github\.com)(?:\/|:)(.+)(?:\.(?:.+)|$)/;
3334

3435

3536
// MAIN //
@@ -52,7 +53,8 @@ function git() {
5253

5354
// Get the local git repository path and remove any newline characters:
5455
dir = exec( 'git rev-parse --show-toplevel' );
55-
dir = dir.toString().match( /(.+)/ )[ 1 ];
56+
dir = trim( dir.toString() );
57+
dir = dir.match( /(.+)/ )[ 1 ];
5658
debug( 'Local repository directory: %s', dir );
5759

5860
opts = {
@@ -62,7 +64,7 @@ function git() {
6264
// Get the remote origin:
6365
cmd = 'git config --get remote.origin.url';
6466
out = exec( cmd, opts );
65-
origin = out.toString();
67+
origin = trim( out.toString() );
6668
debug( 'Remote origin: %s', origin );
6769

6870
// Extract the repository slug:
@@ -72,7 +74,8 @@ function git() {
7274
// Get the current Git hash and remove any newline characters:
7375
cmd = 'git rev-parse HEAD';
7476
out = exec( cmd, opts );
75-
hash = out.toString().match( /(.+)/ )[ 1 ];
77+
out = trim( out.toString() );
78+
hash = out.match( /(.+)/ )[ 1 ];
7679
debug( 'Current hash: %s', hash );
7780

7881
hslug = rslug+'/'+hash;

0 commit comments

Comments
 (0)