Pd Custom Sound

By Takius Stargazer Last update Jun 9, 2011 — Installed 368 times.

RegExp

in
Subscribe to RegExp 1 post, 1 voice

Griphox Scriptwright
FirefoxWindows

Hello, i'm Griph (orion) fellow Uni
looked at the code of the script and would like to share what it says about needing a RegExp for the function checkContent( test), here you can use this:

function checkContent( test) {
return /^https?:\/\//.test( test);
}

Although consider:
1. Recommend to change the name of the parameter, confusing with the TEST js function

2. The whole script only uses checkContent once, you could ditch the function and just put

/^https?:\/\//.test( test)

inside the IF( ) in the fifth line of the findAndPlay() function

3. I strongly recommend you to use TEST function instead of indexOf for string comparison, like when you want to know in which page is being loaded, which screen like between the profile, building or starbase. First because it will make a cleaner code and because you avoid checking against >= 0 or != -1, as the TEST function already returns boolean.

4. Strictly speaking, the script says you could also put a File address but your current checkContent would not allow it, neither the one i wrote above but if you like this would also check and allow File:

/^(https?|file):\/\//.test( string)

To be honest i didn't install the script to test it, so i can't say it really doesn't allows File address, but that IF seems to filter it.