Skip to content
Browse files

describe request rewriting examples

  • Loading branch information...
1 parent 4d6555a commit 4d52d28421131f36a1670101d9360c528fde0365 @kraih committed May 13, 2012
View
2 lib/Mojo/Content.pm
@@ -16,7 +16,7 @@ sub body_size { croak 'Method "body_size" not implemented by subclass' }
sub boundary {
(shift->headers->content_type || '')
- =~ m#multipart.*boundary="*([a-zA-Z0-9'(),.:?\-_+/]+)#i
+ =~ m!multipart.*boundary="*([a-zA-Z0-9'(),.:?\-_+/]+)!i
and return $1;
return;
}
View
2 lib/Mojo/Content/MultiPart.pm
@@ -77,7 +77,7 @@ sub build_boundary {
}
# Add boundary to Content-Type header
- $type =~ m#^(.*multipart/[^;]+)(.*)$#;
+ $type =~ m!^(.*multipart/[^;]+)(.*)$!;
my $before = $1 || 'multipart/mixed';
my $after = $2 || '';
$headers->content_type("$before; boundary=$boundary$after");
View
8 lib/Mojo/DOM/HTML.pm
@@ -22,7 +22,7 @@ my $ATTR_RE = qr/
)?
\s*
/x;
-my $END_RE = qr#^\s*/\s*(.+)\s*#;
+my $END_RE = qr!^\s*/\s*(.+)\s*!;
my $TOKEN_RE = qr/
([^<]*) # Text
(?:
@@ -115,7 +115,7 @@ sub parse {
if ($tag =~ $END_RE) { $self->_end($cs ? $1 : lc($1), \$current) }
# Start
- elsif ($tag =~ m#([^\s/]+)([\s\S]*)#) {
+ elsif ($tag =~ m!([^\s/]+)([\s\S]*)!) {
my ($start, $attr) = ($cs ? $1 : lc($1), $2);
# Attributes
@@ -137,11 +137,11 @@ sub parse {
# Empty element
$self->_end($start, \$current)
- if (!$self->xml && $VOID{$start}) || $attr =~ m#/\s*$#;
+ if (!$self->xml && $VOID{$start}) || $attr =~ m!/\s*$!;
# Relaxed "script" or "style"
if ($start ~~ [qw(script style)]) {
- if ($html =~ m#\G(.*?)<\s*/\s*$start\s*>#gcsi) {
+ if ($html =~ m!\G(.*?)<\s*/\s*$start\s*>!gcsi) {
$self->_raw($1, \$current);
$self->_end($start, \$current);
}
View
4 lib/Mojo/JSON.pm
@@ -170,7 +170,7 @@ sub _decode_string {
# Unescape popular characters
if (index($str, '\\u') < 0) {
- $str =~ s|\\(["\\/bfnrt])|$ESCAPE{$1}|gs;
+ $str =~ s!\\(["\\/bfnrt])!$ESCAPE{$1}!gs;
return $str;
}
@@ -262,7 +262,7 @@ sub _encode_string {
my $string = shift;
# Escape string
- $string =~ s|([\x00-\x1F\x7F\x{2028}\x{2029}\\"/\b\f\n\r\t])|$REVERSE{$1}|gs;
+ $string =~ s!([\x00-\x1F\x7F\x{2028}\x{2029}\\"/\b\f\n\r\t])!$REVERSE{$1}!gs;
# Stringify
return "\"$string\"";
View
2 lib/Mojo/JSON/Pointer.pm
@@ -13,7 +13,7 @@ sub _pointer {
my ($self, $contains, $data, $pointer) = @_;
# Parse pointer and walk data structure
- return unless $pointer =~ s|^/||;
+ return unless $pointer =~ s!^/!!;
for my $p (split '/', $pointer) {
$p = decode('UTF-8', url_unescape $p);
View
4 lib/Mojo/Message.pm
@@ -70,12 +70,12 @@ sub body_params {
# "x-application-urlencoded" and "application/x-www-form-urlencoded"
my $type = $self->headers->content_type || '';
- if ($type =~ m#(?:x-application|application/x-www-form)-urlencoded#i) {
+ if ($type =~ m!(?:x-application|application/x-www-form)-urlencoded!i) {
$p->parse($self->content->asset->slurp);
}
# "multipart/formdata"
- elsif ($type =~ m#multipart/form-data#i) {
+ elsif ($type =~ m!multipart/form-data!i) {
my $formdata = $self->_parse_formdata;
# Formdata
View
14 lib/Mojo/Message/Request.pm
@@ -172,7 +172,7 @@ sub _build_start_line {
my $path = $url->path->to_string;
my $query = $url->query->to_string;
$path .= "?$query" if $query;
- $path = "/$path" unless $path =~ m#^/#;
+ $path = "/$path" unless $path =~ m!^/!;
# CONNECT
my $method = uc $self->method;
@@ -245,7 +245,7 @@ sub _parse_env {
$self->method($env->{REQUEST_METHOD}) if $env->{REQUEST_METHOD};
# Scheme/Version
- if (($env->{SERVER_PROTOCOL} || '') =~ m#^([^/]+)/([^/]+)$#) {
+ if (($env->{SERVER_PROTOCOL} || '') =~ m!^([^/]+)/([^/]+)$!) {
$base->scheme($1);
$self->version($2);
}
@@ -262,14 +262,14 @@ sub _parse_env {
if (my $value = $env->{SCRIPT_NAME}) {
# Make sure there is a trailing slash (important for merging)
- $base->path->parse($value =~ m#/$# ? $value : "$value/");
+ $base->path->parse($value =~ m!/$! ? $value : "$value/");
# Remove SCRIPT_NAME prefix if necessary
my $buffer = $path->to_string;
- $value =~ s|^/||;
- $value =~ s|/$||;
- $buffer =~ s|^/?$value/?||;
- $buffer =~ s|^/||;
+ $value =~ s!^/!!;
+ $value =~ s!/$!!;
+ $buffer =~ s!^/?$value/?!!;
+ $buffer =~ s!^/!!;
$path->parse($buffer);
}
View
4 lib/Mojo/Message/Response.pm
@@ -127,7 +127,7 @@ sub _parse_start_line {
my $self = shift;
# Try to detect HTTP 0.9
- if ($self->{buffer} =~ /^\s*(\S.{4})/ && $1 !~ m#^HTTP/#) {
+ if ($self->{buffer} =~ /^\s*(\S.{4})/ && $1 !~ m!^HTTP/!) {
$self->version('0.9');
$self->content->relaxed(1);
return $self->{state} = 'content';
@@ -136,7 +136,7 @@ sub _parse_start_line {
# We have a full HTTP 1.0+ response line
return unless defined(my $line = get_line \$self->{buffer});
return $self->error('Bad response start line.')
- unless $line =~ m|^\s*HTTP/(\d\.\d)\s+(\d\d\d)\s*(.+)?$|;
+ unless $line =~ m!^\s*HTTP/(\d\.\d)\s+(\d\d\d)\s*(.+)?$!;
$self->version($1)->code($2)->message($3);
$self->content->auto_relax(1);
$self->{state} = 'content';
View
6 lib/Mojo/Path.pm
@@ -65,7 +65,7 @@ sub merge {
my ($self, $path) = @_;
# Replace
- return $self->parse($path) if $path =~ m|^/|;
+ return $self->parse($path) if $path =~ m!^/!;
# Merge
pop @{$self->parts} unless $self->trailing_slash;
@@ -79,8 +79,8 @@ sub parse {
$path = url_unescape $path // '';
utf8::decode $path;
- $path =~ s|^/|| ? $self->leading_slash(1) : $self->leading_slash(undef);
- $path =~ s|/$|| ? $self->trailing_slash(1) : $self->trailing_slash(undef);
+ $path =~ s!^/!! ? $self->leading_slash(1) : $self->leading_slash(undef);
+ $path =~ s!/$!! ? $self->trailing_slash(1) : $self->trailing_slash(undef);
return $self->parts([split '/', $path, -1]);
}
View
2 lib/Mojo/Server/Daemon.pm
@@ -205,7 +205,7 @@ sub _listen {
# Friendly message
return if $self->silent;
$self->app->log->info(qq{Listening at "$listen".});
- $listen =~ s|//\*|//127.0.0.1|i;
+ $listen =~ s!//\*!//127.0.0.1!i;
say "Server available at $listen.";
}
View
2 lib/Mojo/URL.pm
@@ -95,7 +95,7 @@ sub parse {
return $self unless $url;
# Official regex
- $url =~ m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?|;
+ $url =~ m!(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?!;
$self->scheme($1);
$self->authority($2);
$self->path->parse($3);
View
2 lib/Mojo/UserAgent/Transactor.pm
@@ -161,7 +161,7 @@ sub tx {
my $req = $tx->req;
$req->method(shift);
my $url = shift;
- $url = "http://$url" unless $url =~ m#^/|\://#;
+ $url = "http://$url" unless $url =~ m!^/|\://!;
ref $url ? $req->url($url) : $req->url->parse($url);
# Body
View
2 lib/Mojolicious/Command/get.pm
@@ -74,7 +74,7 @@ sub run {
$ua->max_redirects(10) if $redirect;
# Absolute URL
- if ($url !~ m#/#) { $ua->detect_proxy }
+ if ($url !~ m!/!) { $ua->detect_proxy }
# Application
else { $ua->app($ENV{MOJO_APP} || 'Mojo::HelloWorld') }
View
6 lib/Mojolicious/Controller.pm
@@ -468,7 +468,7 @@ sub url_for {
# Absolute URL
return $target if (Scalar::Util::blessed($target) || '') eq 'Mojo::URL';
- return Mojo::URL->new($target) if $target =~ m#^\w+\://#;
+ return Mojo::URL->new($target) if $target =~ m!^\w+\://!;
# Base
my $url = Mojo::URL->new;
@@ -477,11 +477,11 @@ sub url_for {
# Relative URL
my $path = $url->path;
- if ($target =~ m#^/#) {
+ if ($target =~ m!^/!) {
if (my $prefix = $self->stash->{path}) {
my $real = Mojo::Util::url_unescape($req->url->path->to_abs_string);
$real = Mojo::Util::decode('UTF-8', $real) // $real;
- $real =~ s|/?$prefix$|$target|;
+ $real =~ s!/?$prefix$!$target!;
$target = $real;
}
$url->parse($target);
View
2 lib/Mojolicious/Guides/Cookbook.pod
@@ -215,6 +215,7 @@ where you can't just change the server configuration or behind a reverse proxy
that passes along additional information with C<X-*> headers. In such cases
you can use a C<before_dispatch> hook to rewrite incoming requests.
+ # Change scheme if "X-Forwarded-Protocol" header is set to "https"
app->hook(before_dispatch => sub {
my $self = shift;
$self->req->url->base->scheme('https')
@@ -225,6 +226,7 @@ Since reverse proxies generally don't pass along information about path
prefixes your application might be deployed under, rewriting the base path of
incoming requests is also quite common.
+ # Move first part from path to base path in production mode
app->hook(before_dispatch => sub {
my $self = shift;
push @{$self->req->url->base->path->parts},
View
4 lib/Mojolicious/Guides/Routing.pod
@@ -34,7 +34,7 @@ While it is very well possible to make all these connections static, it is
also rather inefficient. That's why regular expressions are commonly used to
make the dispatch process more dynamic.
- qr|/user/show/(\d+)| -> $self->render(text => $users{$1});
+ qr!/user/show/(\d+)! -> $self->render(text => $users{$1});
Modern dispatchers have pretty much everything HTTP has to offer at their
disposal and can use many more variables than just the request path, such as
@@ -50,7 +50,7 @@ request method and headers like C<Host>, C<User-Agent> and C<Accept>.
While regular expressions are quite powerful they also tend to be unpleasant
to look at and are generally overkill for ordinary path matching.
- qr|/user/show/(\d+)| -> $self->render(text => $users{$1});
+ qr!/user/show/(\d+)! -> $self->render(text => $users{$1});
This is where routes come into play, they have been designed from the ground
up to represent paths with placeholders.
View
2 lib/Mojolicious/Plugin/Mount.pm
@@ -12,7 +12,7 @@ sub register {
# Extract host
my $host;
- if ($path =~ m#^(\*\.)?([^/]+)(/.*)?$#) {
+ if ($path =~ m!^(\*\.)?([^/]+)(/.*)?$!) {
$host = $1 ? qr/^(?:.*\.)?\Q$2\E$/i : qr/^\Q$2\E$/i;
$path = $3;
}
View
10 lib/Mojolicious/Plugin/PODRenderer.pm
@@ -42,7 +42,7 @@ sub register {
# Find module
my $module = $self->param('module');
- $module =~ s|/|\:\:|g;
+ $module =~ s!/!\:\:!g;
my $path = Pod::Simple::Search->new->find($module, @PATHS);
# Redirect to CPAN
@@ -59,9 +59,9 @@ sub register {
$dom->find('a[href]')->each(
sub {
my $attrs = shift->attrs;
- $attrs->{href} =~ s|%3A%3A|/|gi
+ $attrs->{href} =~ s!%3A%3A!/!gi
if $attrs->{href}
- =~ s|^http\://search\.cpan\.org/perldoc\?|$perldoc|;
+ =~ s!^http\://search\.cpan\.org/perldoc\?!$perldoc!;
}
);
@@ -129,8 +129,8 @@ sub _pod_to_html {
return $@ unless eval { $parser->parse_string_document("$pod"); 1 };
# Filter
- $output =~ s|<a name='___top' class='dummyTopAnchor'\s*?></a>\n||g;
- $output =~ s|<a class='u'.*?name=".*?"\s*>(.*?)</a>|$1|sg;
+ $output =~ s!<a name='___top' class='dummyTopAnchor'\s*?></a>\n!!g;
+ $output =~ s!<a class='u'.*?name=".*?"\s*>(.*?)</a>!$1!sg;
return $output;
}
View
2 lib/Mojolicious/Routes.pm
@@ -52,7 +52,7 @@ sub dispatch {
# Prepare path
my $req = $c->req;
my $path = $c->stash->{path};
- if (defined $path) { $path = "/$path" if $path !~ m#^/# }
+ if (defined $path) { $path = "/$path" if $path !~ m!^/! }
else { $path = $req->url->path->to_abs_string }
# Prepare match
View
8 lib/Mojolicious/Routes/Pattern.pm
@@ -24,7 +24,7 @@ sub parse {
# Make sure we have a viable pattern
my $pattern = @_ % 2 ? (shift || '/') : '/';
- $pattern = "/$pattern" unless $pattern =~ m#^/#;
+ $pattern = "/$pattern" unless $pattern =~ m!^/!;
# Requirements
$self->reqs({@_});
@@ -95,7 +95,7 @@ sub shape_match {
# Format
my $req = $self->reqs->{format};
return $result if !$detect || defined $req && !$req;
- if ($$pathref =~ s|^/?$format||) { $result->{format} = $1 }
+ if ($$pathref =~ s!^/?$format!!) { $result->{format} = $1 }
elsif ($req) { return unless $result->{format} }
return $result;
@@ -168,13 +168,13 @@ sub _compile_format {
# Default regex
my $reqs = $self->reqs;
- return $self->format(qr#\.([^/]+)$#)->format
+ return $self->format(qr!\.([^/]+)$!)->format
if !exists $reqs->{format} && $reqs->{format};
# Compile custom regex
my $regex
= defined $reqs->{format} ? _compile_req($reqs->{format}) : '([^/]+)';
- return $self->format(qr#\.$regex$#)->format;
+ return $self->format(qr!\.$regex$!)->format;
}
# "Interesting... Oh no wait, the other thing, tedious."
View
4 t/mojo/app.t
@@ -114,7 +114,7 @@ $id = Mojo::IOLoop->client(
Mojo::IOLoop->remove($id) and Mojo::IOLoop->stop
if $buffer =~ s/ is working!$//;
$stream->write('4321')
- if $buffer =~ m#HTTP/1.1 100 Continue.*\x0d\x0a\x0d\x0a#gs;
+ if $buffer =~ m!HTTP/1.1 100 Continue.*\x0d\x0a\x0d\x0a!gs;
}
);
$stream->write("GET /1/ HTTP/1.1\x0d\x0a"
@@ -123,7 +123,7 @@ $id = Mojo::IOLoop->client(
}
);
Mojo::IOLoop->start;
-like $buffer, qr#HTTP/1.1 100 Continue.*Mojo$#s, 'request was continued';
+like $buffer, qr!HTTP/1.1 100 Continue.*Mojo$!s, 'request was continued';
# Pipelined
$buffer = '';
View
6 t/mojo/request.t
@@ -1839,7 +1839,7 @@ is $req->url, '/', 'right URL';
is $req->cookie('mojolicious')->value,
'BAcIMTIzNDU2NzgECAgIAwIAAAAXDGFsZXgudm9yb25vdgQAAAB1c2VyBp6FjksAAAAABwA'
. 'AAGV4cGlyZXM=--1641adddfe885276cda0deb7475f153a', 'right value';
-like $req->headers->content_type, qr#multipart/form-data#,
+like $req->headers->content_type, qr!multipart/form-data!,
'right "Content-Type" value';
is $req->param('fname'), 'Иван', 'right value';
is $req->param('sname'), 'Иванов', 'right value';
@@ -1911,7 +1911,7 @@ is $req->url, '/', 'right URL';
is $req->cookie('mojolicious')->value,
'BAcIMTIzNDU2NzgECAgIAwIAAAAXDGFsZXgudm9yb25vdgQAAAB1c2VyBiWFjksAAAAABwA'
. 'AAGV4cGlyZXM=--cd933a37999e0fa8d7804205e89193a7', 'right value';
-like $req->headers->content_type, qr#multipart/form-data#,
+like $req->headers->content_type, qr!multipart/form-data!,
'right "Content-Type" value';
is $req->param('fname'), 'Иван', 'right value';
is $req->param('sname'), 'Иванов', 'right value';
@@ -1978,7 +1978,7 @@ is $req->url, '/', 'right URL';
is $req->cookie('mojolicious')->value,
'BAcIMTIzNDU2NzgECAgIAwIAAAAXDGFsZXgudm9yb25vdgQAAAB1c2VyBhaIjksAAAAABwA'
. 'AAGV4cGlyZXM=--78a58a94f98ae5b75a489be1189f2672', 'right value';
-like $req->headers->content_type, qr#multipart/form-data#,
+like $req->headers->content_type, qr!multipart/form-data!,
'right "Content-Type" value';
is $req->param('fname'), 'Иван', 'right value';
is $req->param('sname'), 'Иванов', 'right value';
View
4 t/mojo/response.t
@@ -313,7 +313,7 @@ is $res->message, 'OK', 'right message';
is $res->version, '1.1', 'right version';
ok $res->at_least_version('1.0'), 'at least version 1.0';
ok !$res->at_least_version('1.2'), 'not version 1.2';
-ok $res->headers->content_type =~ m#multipart/form-data#,
+ok $res->headers->content_type =~ m!multipart/form-data!,
'right "Content-Type" value';
isa_ok $res->content->parts->[0], 'Mojo::Content::Single', 'right part';
isa_ok $res->content->parts->[1], 'Mojo::Content::Single', 'right part';
@@ -346,7 +346,7 @@ is $res->message, 'OK', 'right message';
is $res->version, '1.1', 'right version';
ok $res->at_least_version('1.0'), 'at least version 1.0';
ok !$res->at_least_version('1.2'), 'not version 1.2';
-ok $res->headers->content_type =~ m#multipart/form-data#,
+ok $res->headers->content_type =~ m!multipart/form-data!,
'right "Content-Type" value';
isa_ok $res->content, 'Mojo::Content::Single', 'right content';
like $res->content->asset->slurp, qr/hallo welt/, 'right content';
View
4 t/mojo/user_agent.t
@@ -254,8 +254,8 @@ is scalar @{Mojo::IOLoop->stream($tx->connection)->subscribers('write')}, 0,
'unsubscribed successfully';
is scalar @{Mojo::IOLoop->stream($tx->connection)->subscribers('read')}, 1,
'unsubscribed successfully';
-like $req, qr#^GET / .*whatever$#s, 'right request';
-like $res, qr#^HTTP/.*200 OK.*works!$#s, 'right response';
+like $req, qr!^GET / .*whatever$!s, 'right request';
+like $res, qr|^HTTP/.*200 OK.*works!$|s, 'right response';
$ua->unsubscribe(start => $start);
ok !$ua->has_subscribers('start'), 'unsubscribed successfully';
View
4 t/mojo/websocket.t
@@ -161,7 +161,7 @@ websocket '/timeout' => sub {
my $ua = app->ua;
my $res = $ua->get('/link')->success;
is $res->code, 200, 'right status';
-like $res->body, qr#ws\://localhost\:\d+/#, 'right content';
+like $res->body, qr!ws\://localhost\:\d+/!, 'right content';
# GET /socket (plain HTTP request)
$res = $ua->get('/socket')->res;
@@ -186,7 +186,7 @@ $ua->websocket(
}
);
$loop->start;
-like $result, qr#test1test2ws\://localhost\:\d+/#, 'right result';
+like $result, qr!test1test2ws\://localhost\:\d+/!, 'right result';
# WebSocket /something/else (failed websocket connection)
my ($code, $body, $ws);
View
16 t/mojolicious/app.t
@@ -145,19 +145,19 @@ $t->get_ok('/foo/test', {'X-Test' => 'Hi there!'})->status_is(200)
->header_is('X-Bender' => 'Bite my shiny metal ass!')
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
- ->content_like(qr#/bar/test#);
+ ->content_like(qr!/bar/test!);
# Foo::index
$t->get_ok('/foo', {'X-Test' => 'Hi there!'})->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
- ->content_like(qr#<body>\s+23\nHello Mojo from the template /foo! He#);
+ ->content_like(qr|<body>\s+23\nHello Mojo from the template /foo! He|);
# Foo::Bar::index
$t->get_ok('/foo-bar', {'X-Test' => 'Hi there!'})->status_is(200)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
- ->content_like(qr#Hello Mojo from the other template /foo-bar!#);
+ ->content_like(qr|Hello Mojo from the other template /foo-bar!|);
# Foo::something
$t->get_ok('/somethingtest', {'X-Test' => 'Hi there!'})->status_is(200)
@@ -194,7 +194,7 @@ $t->get_ok('/test2', {'X-Test' => 'Hi there!'})->status_is(200)
->header_is('X-Bender' => 'Bite my shiny metal ass!')
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
- ->content_like(qr#/test2#);
+ ->content_like(qr!/test2!);
# MojoliciousTestController::index
$t->get_ok('/test3', {'X-Test' => 'Hi there!'})->status_is(200)
@@ -273,7 +273,7 @@ $tx->req->method('GET');
$tx->req->url->parse('/foo');
$app->handler($tx);
is $tx->res->code, 200, 'right status';
-like $tx->res->body, qr#Hello Mojo from the template /foo! Hello World!#,
+like $tx->res->body, qr|Hello Mojo from the template /foo! Hello World!|,
'right content';
$tx = Mojo::Transaction::HTTP->new;
$tx->req->method('GET');
@@ -286,7 +286,7 @@ $tx->req->method('GET');
$tx->req->url->parse('/foo');
$app->handler($tx);
is $tx->res->code, 200, 'right status';
-like $tx->res->body, qr#Hello Mojo from the template /foo! Hello World!#,
+like $tx->res->body, qr|Hello Mojo from the template /foo! Hello World!|,
'right content';
$t = Test::Mojo->new('SingleFileTestApp');
@@ -393,9 +393,9 @@ $t->get_ok('/shortcut/act')->status_is(200)
# Session with domain
$t->get_ok('/foo/session')->status_is(200)
->header_like('Set-Cookie' => qr/; domain=\.example\.com/)
- ->header_like('Set-Cookie' => qr|; path=/bar|)
+ ->header_like('Set-Cookie' => qr!; path=/bar!)
->content_is('Bender rockzzz!');
# Mixed formats
$t->get_ok('/rss.xml')->status_is(200)->content_type_is('application/rss+xml')
- ->content_like(qr#<\?xml version="1.0" encoding="UTF-8"\?><rss />#);
+ ->content_like(qr!<\?xml version="1.0" encoding="UTF-8"\?><rss />!);
View
10 t/mojolicious/exception_lite_app.t
@@ -130,11 +130,11 @@ like $log, qr/fatal:five/, 'right result';
# GET /does_not_exist ("not_found.development.html.ep" route suggestion)
$t->get_ok('/does_not_exist')->status_is(404)
- ->content_like(qr#/does_not_exist#);
+ ->content_like(qr!/does_not_exist!);
# POST /does_not_exist ("not_found.development.html.ep" route suggestion)
$t->post_ok('/does_not_exist')->status_is(404)
- ->content_like(qr#/does_not_exist#);
+ ->content_like(qr!/does_not_exist!);
# GET /dead_template
$t->get_ok('/dead_template')->status_is(500)->content_like(qr/1\./)
@@ -151,7 +151,7 @@ $t->get_ok('/dead_template_with_layout')->status_is(500)->content_like(qr/2\./)
# GET /dead_action
$t->get_ok('/dead_action')->status_is(500)
->content_type_is('text/html;charset=UTF-8')
- ->content_like(qr|get &#39;/dead_action&#39;|)
+ ->content_like(qr!get &#39;/dead_action&#39;!)
->content_like(qr/dead action!/);
# GET /dead_action.xml (different format)
@@ -161,12 +161,12 @@ $t->get_ok('/dead_action.xml')->status_is(500)->content_type_is('text/xml')
# GET /dead_action.json (unsupported format)
$t->get_ok('/dead_action.json')->status_is(500)
->content_type_is('text/html;charset=UTF-8')
- ->content_like(qr|get &#39;/dead_action&#39;|)
+ ->content_like(qr!get &#39;/dead_action&#39;!)
->content_like(qr/dead action!/);
# GET /double_dead_action_☃
$t->get_ok('/double_dead_action_☃')->status_is(500)
- ->content_like(qr|get &#39;/double_dead_action_☃&#39;.*lite_app\.t\:\d|s)
+ ->content_like(qr!get &#39;/double_dead_action_☃&#39;.*lite_app\.t\:\d!s)
->content_like(qr/double dead action!/);
# GET /trapped
View
26 t/mojolicious/lite_app.t
@@ -821,7 +821,7 @@ $t->get_ok(
$t->ua->app_url->userinfo('sri:foo')->path('/stream')->query(foo => 'bar'))
->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
- ->content_like(qr#^foobarsri\:foohttp://localhost\:\d+/stream$#);
+ ->content_like(qr!^foobarsri\:foohttp://localhost\:\d+/stream$!);
# GET /maybe/ajax (not ajax)
$t->get_ok('/maybe/ajax')->status_is(200)
@@ -869,25 +869,25 @@ $t->get_ok('/.html')->status_is(200)->header_is(Server => 'Mojolicious (Perl)')
# GET /0 ("X-Forwarded-For")
my $source = $t->tx->local_address;
$t->get_ok('/0', {'X-Forwarded-For' => '192.168.2.2, 192.168.2.1'})
- ->status_is(200)->content_like(qr#http\://localhost\:\d+/0-$source-0#);
+ ->status_is(200)->content_like(qr!http\://localhost\:\d+/0-$source-0!);
# GET /0 ("X-Forwarded-HTTPS")
$t->get_ok('/0', {'X-Forwarded-HTTPS' => 1})->status_is(200)
- ->content_like(qr#http\://localhost\:\d+/0-$source-0#);
+ ->content_like(qr!http\://localhost\:\d+/0-$source-0!);
# GET /0 (reverse proxy with "X-Forwarded-For")
{
local $ENV{MOJO_REVERSE_PROXY} = 1;
$t->get_ok('/0', {'X-Forwarded-For' => '192.168.2.2, 192.168.2.1'})
->status_is(200)
- ->content_like(qr#http\://localhost\:\d+/0-192\.168\.2\.1-0#);
+ ->content_like(qr!http\://localhost\:\d+/0-192\.168\.2\.1-0!);
}
# GET /0 (reverse proxy with "X-Forwarded-HTTPS")
{
local $ENV{MOJO_REVERSE_PROXY} = 1;
$t->get_ok('/0', {'X-Forwarded-HTTPS' => 1})->status_is(200)
- ->content_like(qr#https\://localhost\:\d+/0-$source-0#);
+ ->content_like(qr!https\://localhost\:\d+/0-$source-0!);
}
# DELETE /inline/epl
@@ -904,7 +904,7 @@ $t->get_ok('/inline/ep/partial')->status_is(200)
->content_is("♥just ♥\nworks!\n");
# GET /source
-$t->get_ok('/source')->status_is(200)->content_like(qr#get_ok\('/source#);
+$t->get_ok('/source')->status_is(200)->content_like(qr!get_ok\('/source!);
# GET /source (file does not exist)
$t->get_ok('/source?fail=1')->status_is(404)->content_is('does not exist!');
@@ -943,7 +943,7 @@ $t->get_ok('/foo_wildcard_too/')->status_is(404);
# GET /with/header/condition
$t->get_ok('/with/header/condition', {'X-Secret-Header' => 'bar'})
- ->status_is(200)->content_like(qr#^Test ok<base href="http://localhost#);
+ ->status_is(200)->content_like(qr!^Test ok<base href="http://localhost!);
# GET /with/header/condition (not found)
$t->get_ok('/with/header/condition')->status_is(404)->content_like(qr/Oops!/);
@@ -1181,22 +1181,22 @@ $t->get_ok('/redirect_path')->status_is(302)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->header_is('Content-Length' => 12)
- ->header_like(Location => qr#/foo/bar\?foo=bar$#)
+ ->header_like(Location => qr!/foo/bar\?foo=bar$!)
->content_is('Redirecting!');
# GET /redirect_named
$t->get_ok('/redirect_named')->status_is(302)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->header_is('Content-Length' => 12)
- ->header_like(Location => qr#/template.txt$#)->content_is('Redirecting!');
+ ->header_like(Location => qr!/template.txt$!)->content_is('Redirecting!');
# GET /redirect_no_render
$t->get_ok('/redirect_no_render')->status_is(302)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
->header_is('Content-Length' => 0)
- ->header_like(Location => qr#/template.txt$#)->content_is('');
+ ->header_like(Location => qr!/template.txt$!)->content_is('');
# GET /redirect_callback
$t->get_ok('/redirect_callback')->status_is(301)
@@ -1225,7 +1225,7 @@ $t->ua->max_redirects(0);
Test::Mojo->new->tx($t->tx->previous)->status_is(302)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
- ->header_like(Location => qr#/template.txt$#)->content_is('Redirecting!');
+ ->header_like(Location => qr!/template.txt$!)->content_is('Redirecting!');
# GET /koi8-r
my $koi8
@@ -1295,7 +1295,7 @@ $t->get_ok('/redirect/condition/0')->status_is(200)
$t->get_ok('/redirect/condition/1')->status_is(302)
->header_is(Server => 'Mojolicious (Perl)')
->header_is('X-Powered-By' => 'Mojolicious (Perl)')
- ->header_like('Location' => qr#/template$#)->content_is('');
+ ->header_like('Location' => qr!/template$!)->content_is('');
# GET /redirect/condition/1 (with condition header)
$t->get_ok('/redirect/condition/1' => {'X-Condition-Test' => 1})
@@ -1337,7 +1337,7 @@ EOF
# GET /url_with/foo
$t->get_ok('/url_with/foo?foo=bar')->status_is(200)
- ->content_like(qr|http\://localhost\:\d+/url_with/bar\?foo\=bar|);
+ ->content_like(qr!http\://localhost\:\d+/url_with/bar\?foo\=bar!);
# GET /dynamic/inline
$t->get_ok('/dynamic/inline')->status_is(200)
View
8 t/mojolicious/pod_renderer_lite_app.t
@@ -40,16 +40,16 @@ my $t = Test::Mojo->new;
# Simple POD template
$t->get_ok('/')->status_is(200)
- ->content_like(qr#<h1>Test123</h1>\s+<p>It <code>works</code>!</p>#);
+ ->content_like(qr|<h1>Test123</h1>\s+<p>It <code>works</code>!</p>|);
# POD helper
$t->post_ok('/')->status_is(200)
- ->content_like(qr#test123\s+<h1>A</h1>\s+<h1>B</h1>#)
- ->content_like(qr#\s+<p><code>test</code></p>#)->content_like(qr/Gray/);
+ ->content_like(qr!test123\s+<h1>A</h1>\s+<h1>B</h1>!)
+ ->content_like(qr!\s+<p><code>test</code></p>!)->content_like(qr/Gray/);
# POD filter
$t->post_ok('/block')->status_is(200)
- ->content_like(qr#test321\s+<h2>lalala</h2>\s+<p><code>test</code></p>#)
+ ->content_like(qr!test321\s+<h2>lalala</h2>\s+<p><code>test</code></p>!)
->content_like(qr/Gray/);
# Empty
View
6 t/mojolicious/twinkle_lite_app.t
@@ -61,13 +61,13 @@ $t->get_ok('/advanced')->status_is(200)
->content_is("&lt;escape me&gt;\n123423");
# GET /docs
-$t->get_ok('/docs')->status_is(200)->content_like(qr#<h3>snowman</h3>#);
+$t->get_ok('/docs')->status_is(200)->content_like(qr!<h3>snowman</h3>!);
# GET /docs2
-$t->get_ok('/docs2')->status_is(200)->content_like(qr#<h2>snowman</h2>#);
+$t->get_ok('/docs2')->status_is(200)->content_like(qr!<h2>snowman</h2>!);
# GET /docs3
-$t->get_ok('/docs3')->status_is(200)->content_like(qr#<h3></h3>#);
+$t->get_ok('/docs3')->status_is(200)->content_like(qr!<h3></h3>!);
# GET /perldoc (disabled)
$t->get_ok('/perldoc')->status_is(404);
View
2 t/mojolicious/upload_lite_app.t
@@ -59,7 +59,7 @@ $t->post_form_ok('/upload',
# POST /upload (path)
$t->post_form_ok('/upload', {file => {file => $file->path}, test => 'foo'})
- ->status_is(200)->content_like(qr#lalalafoofile,test$#);
+ ->status_is(200)->content_like(qr!lalalafoofile,test$!);
# POST /upload (memory)
$t->post_form_ok('/upload', {file => {content => 'alalal'}, test => 'tset'})

0 comments on commit 4d52d28

Please sign in to comment.
Something went wrong with that request. Please try again.