Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Providing a base path and loading absolute URLs #22

Closed
bmcclure opened this issue Sep 26, 2011 · 4 comments
Closed

Providing a base path and loading absolute URLs #22

bmcclure opened this issue Sep 26, 2011 · 4 comments

Comments

@bmcclure
Copy link

I always provide a base path pointing to the location where my JS files are located, but it makes loading files from an absolute URL more difficult (Must remember to use $script.get directly) and more limited ($script() adds a lot of nice things over $script.get that are lost when calling $script.get directly).

Wouldn't it make sense to check if a script path is a valid URL already before prepending the configured base path? I can't think of a scenario when someone would supply a base path, and then expect that it will be prepended when they supply an absolute URL to $script(). I think the expected functionality in at least the majority of cases would be that the base path is prepended only to relative URLs, while absolute URLs are passed through unaltered.

In its current state, supplying a base path makes loading JS from an absolute URL lose all the benefits that $script() adds on top of $script.get(), which seems like a bigger downside than the performance hit that making an extra string check in $script() would make. If performance is a worry, there could be a simple boolean setting in $script which tells it whether or not to check for absolute URLs, which could even default to off so that it works as it did before unless set.

What are your thoughts on this? Are there any other reasons that I'm overlooking for why that might not be preferred to the current functionality?

Thanks!

@ded
Copy link
Owner

ded commented Sep 27, 2011

I would prefer this functionality you're talking about as I've definitely ran into this issue myself. I'll see if there's something I could add in that won't bulk up the library

@bmcclure
Copy link
Author

Awesome, thanks for looking into it!

@ded ded closed this as completed in 811e19a Sep 27, 2011
@ded
Copy link
Owner

ded commented Sep 27, 2011

rudimentary support for this has been added. if you're setting $script.path('foo/bar/') you can get around it with anything that matches ^https?:\/\/

cheers

@bmcclure
Copy link
Author

Thanks, that sounds absolutely perfect! I will be making extensive use of this in most of my CakePHP apps, so I'll let you know if I run into any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants