Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pquery
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
pquery
Commits
7f57b354
Commit
7f57b354
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Added full unit test suite for URL plugin.
parent
a6e7de46
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pquery.url.php
+16
-14
16 additions, 14 deletions
pquery.url.php
with
16 additions
and
14 deletions
pquery.url.php
+
16
−
14
View file @
7f57b354
...
...
@@ -34,20 +34,6 @@ class pQueryUrl extends pQuery {
return
preg_replace
(
'%(^/|/$)%'
,
''
,
$url
);
}
/**
* Execute the handler of the first matching URL regex.
*
* @param string $path The path to add.
* @param bool $relative Indicates whether the path is relative to the document root.
*/
function
handler
()
{
foreach
(
self
::
$handlers
as
$pattern
=>
$handler
)
if
(
preg_match
(
$pattern
,
$this
->
url
,
$matches
)
)
return
call_user_func_array
(
$handler
,
array_slice
(
$matches
,
1
));
//self::error('URL has no handler.', $this->url);
}
/**
* Add a handler function to a URL match.
*
...
...
@@ -68,6 +54,22 @@ class pQueryUrl extends pQuery {
foreach
(
$handlers
as
$pattern
=>
$handler
)
self
::
add_handler
(
$pattern
,
$handler
);
}
/**
* Execute the handler of the first matching URL regex.
*
* @param string $path The path to add.
* @param bool $relative Indicates whether the path is relative to the document root.
*/
function
handler
()
{
foreach
(
self
::
$handlers
as
$pattern
=>
$handler
)
if
(
preg_match
(
$pattern
,
$this
->
url
,
$matches
)
)
return
call_user_func_array
(
$handler
,
array_slice
(
$matches
,
1
));
self
::
error
(
'URL "%s" has no handler.'
,
$this
->
url
);
// @codeCoverageIgnoreStart
}
// @codeCoverageIgnoreEnd
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment