texas697
texas697

Reputation: 6417

how to manipulate a url with javascript

having some trouble altering a url when the filename will change every time.

this is the url i am returning from api. the pdf name will be different evertime

C:/Users/rsanchez/Source/completePdfs/PdfSharpResult-6-23-2015 2-13 PM.pdf

I need to change it to this

ViewerJS/#../completePdfs/PdfSharpResult-6-23-2015 2-13 PM.pdf

what I am trying so far

  var fileURL = result.FileName;
                               fileURL.replace('C:/Users/rsanchez/Source/completePdfs/', 'ViewerJS/#../completePdfs/')
  $scope.returnedPdf = fileURL;
  console.log(fileURL)

Upvotes: 3

Views: 222

Answers (1)

Nikhil Aggarwal
Nikhil Aggarwal

Reputation: 28475

You are doing it alright. Just assign the update value back to fileURL

fileURL = fileURL.replace('C:/Users/rsanchez/Source/completePdfs/', 'ViewerJS/#../completePdfs/')

Upvotes: 4

Related Questions