JavaScript stream_is_local
string stream_resolve_include_path(string filename[, resource context]) U
1 2 3 4 56 7 8 9 1011 12 13 14 | function stream_is_local (stream_or_url) { // string stream_resolve_include_path(string filename[, resource context]) U // // version: 1008.1718 // discuss at: http://phpjs.org/functions/stream_is_local // + original by: Brett Zamir (http://brett-zamir.me) // * example 1: stream_is_local('/etc'); // * returns 1: true if (typeof stream_or_url === 'string') { return ((/^(https?|ftps?|ssl|tls):/).test(stream_or_url)) ? false : true; // Need a better check than this } return stream_or_url.is_local ? true : false; } |
Examples
Running
1 | stream_is_local('/etc'); |
Should return
1 | true |
Dependencies
No dependencies, you can use this function standalone.
Open syntax issues
php.js uses JsLint to help us keep our code consistent and prevent some common bugs.
Eventually we want all code to pass or at least take into consideration most fixes suggested by JsLint, following this JsLint configuration we’ve decided on.
Authors
Thanks to the following developers, you get to have stream_is_local goodness in JavaScript.
No comments yet. Be the first!
spread the word:
Use any PHP function in JavaScript
These kind folks have already donated: @HalfWinter, Paulo Freitas, Andros Peña Romo, Nitin Gupta, @nikosdion, Anonymous, Anonymous and Shawn Houser.
<your name here>