phpjs
Version:
48 lines (40 loc) • 1.39 kB
Markdown
layout: page
title: "JavaScript stream_is_local function"
comments: true
sharing: true
footer: true
alias:
- /functions/view/stream_is_local:851
- /functions/view/stream_is_local
- /functions/view/851
- /functions/stream_is_local:851
- /functions/851
<!-- Generated by Rakefile:build -->
A JavaScript equivalent of PHP's stream_is_local
{% codeblock stream/stream_is_local.js lang:js https://raw.github.com/kvz/phpjs/master/functions/stream/stream_is_local.js raw on github %}
function stream_is_local (stream_or_url) {
// http://kevin.vanzonneveld.net
// + 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;
}
{% endcodeblock %}
- [view on github](https://github.com/kvz/phpjs/blob/master/functions/stream/stream_is_local.js)
- [edit on github](https://github.com/kvz/phpjs/edit/master/functions/stream/stream_is_local.js)
### Example 1
This code
{% codeblock lang:js example %}
stream_is_local('/etc');
{% endcodeblock %}
Should return
{% codeblock lang:js returns %}
true
{% endcodeblock %}
### Other PHP functions in the stream extension
{% render_partial _includes/custom/stream.html %}