Last active
March 24, 2017 11:07
Revisions
-
JonathanDn revised this gist
Mar 24, 2017 . 1 changed file with 10 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,18 @@ export function format(str, argumentsArr?) { let urlConstruct = str; for (var i = 0; i < argumentsArr.length; i++) { // g - global search, m - multiline let regEx = new RegExp("\\{" + (i) + "\\}", 'gm'); // Handle multiple whitespaces in STRING type arguments if (typeof(argumentsArr[i]) === 'string') { argumentsArr[i] = argumentsArr[i].replace(/\s/g, ''); } // Add to url construct urlConstruct = urlConstruct.replace(regEx, argumentsArr[i]); } return urlConstruct; } // Will work like so(endless amount of args): // url should look like this to work : http://{0}/{1}/{2} and so on... format(str, 1stArg?, 2ndArg?, 3rdArg?) -
JonathanDn revised this gist
Mar 24, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,4 +9,5 @@ export function urlFormat(str) { } // Will work like so(endless amount of args): // url should look like this to work : http://{0}/{1}/{2} and so on... urlFormat(str, 1stArg?, 2ndArg?, 3rdArg?) -
JonathanDn renamed this gist
Mar 24, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
JonathanDn created this gist
Mar 24, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ export function urlFormat(str) { let urlConstruct = str; for (var i = 1; i < arguments.length; i++) { // g - global search, m - multiline let regEx = new RegExp("\\{" + (i - 1) + '"\\}', 'gm') urlConstruct = urlConstruct.replace(regEx, arguments[i]); } return urlConstruct; } // Will work like so(endless amount of args): urlFormat(str, 1stArg?, 2ndArg?, 3rdArg?)