archan937 / topup

The #1 Javascript Pop Up / Lightbox made by Paul Engel
http://gettopup.com
158 stars 32 forks source link

Regular expression for scriptHost doesn't work for some urls [Fix included!] #19

Open jpadvo opened 14 years ago

jpadvo commented 14 years ago

[I'm a noob. I learned about the ability to request a pull, so I did that with this code. Cheers! ]

I am building a wordpress theme, and have topup installed in a folder with this url:

http://localhost/project_name/wp-content/themes/theme_name/topup/javascripts/top_up.js

But scriptHost returns as follows:

http://localhost/images/top_up/

This can be fixed by replacing the regular expression inside scriptHost (line 15) as follows:

current: /^\w+:\/\// fixed: /.\/(?=([^\/])(\/[^\/]*)$)/

This uses a positive lookahead to trim off 'javascripts/top_up.js' or 'javascripts/top_up-min.js'.