Jump to content


Photo

function: prepend


4 replies to this topic

#1 shawn

shawn
  • Moderators
  • 800 posts

Posted 29 April 2015 - 12:07 AM

Feature request for a function that only prepends the text if a certain condition is met.

 

For example, the parsed download for LicenseCrawler now includes the full domain. I imagine this will change shortly and return to just the relative path name. Instead of updating my app profile, I'd like to be able to prepend the protocol and domain name ONLY when a protocol and domain name aren't there.

 

In context I imagine it would go something like this, the logic being presented as, "if '//' isn't included in the variable value, prepend the value with x". Note that since multiple instances of ":" are expected (especially for prepended text) everything after the first separator should be ignored.

 

{download:prepend://:http://example.com}


#2 MAPJe71

MAPJe71
  • Members
  • 28 posts
  • LocationThe Netherlands

Posted 29 April 2015 - 03:26 PM

Couldn't you solve this like so:

 

    {download:regexreplace:^//:http\://example.com}



#3 shawn

shawn
  • Moderators
  • 800 posts

Posted 29 April 2015 - 03:45 PM

No. The regexreplace example you've provided would replace an instance of // with the protocol and domain if it appears at the beginning of a string (//path/file.ext), but it would not replace anything if the text "//" doesn't appear.



#4 MAPJe71

MAPJe71
  • Members
  • 28 posts
  • LocationThe Netherlands

Posted 30 April 2015 - 03:49 PM

This function call:

 

    {download:regexreplace:^(?!http\://example.com)/?(\w):http\://example.com/\1}

 

changes the download values:

 

    /relativepath
    relativepath
    http://example.com/relativepath
 

to:

 

    http://example.com/relativepath



#5 MAPJe71

MAPJe71
  • Members
  • 28 posts
  • LocationThe Netherlands

Posted 03 December 2016 - 12:35 AM

An update after re-reading this topic...

 

This function call:

 

    {download:regexreplace:^(?!http\://example.com)/{0,2}(\w):http\://example.com/\1}

 

changes the download values:

 

    //path/file.ext

    /relativepath
    relativepath
    http://example.com/relativepath
 

to:

 

    http://example.com/relativepath





Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users