PHP_URL_HOST
, а дальше сравниваем на эквивалентность.// Code goes here
jQuery(function ($) {
var $checkbox = $(':checkbox');
var $result = $('#result');
var selected = [];
$checkbox.on('change', function () {
var $this = $(this);
var isChecked = $this.is(':checked');
var value = $this.data('value');
console.log(isChecked, value);
if (isChecked) {
selected.push(value);
} else {
selected.splice(
selected.indexOf(value),
1
);
}
setResult();
});
function setResult() {
$result.html(selected.join(', ') || 'Nothing');
}
setResult();
});
# File actionview/lib/action_view/helpers/tag_helper.rb, line 103
def content_tag(name, content_or_options_with_block = nil, options = nil, escape = true, &block)
if block_given?
options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)
content_tag_string(name, capture(&block), options, escape)
else
content_tag_string(name, content_or_options_with_block, options, escape)
end
end
# File actionview/lib/action_view/helpers/capture_helper.rb, line 36
def capture(*args)
value = nil
buffer = with_output_buffer { value = yield(*args) }
if string = buffer.presence || value and string.is_a?(String)
ERB::Util.html_escape string
end
end
<?php
function extract_host($url)
{
if (preg_match('~^https?://(?:www\.)?([^/]+)~', $url, $m)) {
return $m[1];
}
return null;
}
var_dump(extract_host('http://example.com/go/d5863567e7544ae94c5c9342837dbbf8'));
var_dump(extract_host('http://www.example.com/go/d5863567e7544ae94c5c9342837dbbf8'));
string(11) "example.com"
string(11) "example.com"