Skip to content

Commit

Permalink
refactor(router): simplify regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed Dec 9, 2016
1 parent fc97a32 commit d75f170
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions modules/@angular/router/src/url_tree.ts
Expand Up @@ -393,21 +393,23 @@ function pairs<T>(obj: {[key: string]: T}): Pair<string, T>[] {
return res;
}

const SEGMENT_RE = /^[^\/\(\)\?;=&#]+/;
const SEGMENT_RE = /^[^\/()?;=&#]+/;
function matchSegments(str: string): string {
SEGMENT_RE.lastIndex = 0;
const match = str.match(SEGMENT_RE);
return match ? match[0] : '';
}

const QUERY_PARAM_RE = /^[^=\?&#]+/;
const QUERY_PARAM_RE = /^[^=?&#]+/;
// Return the name of the query param at the start of the string or an empty string
function matchQueryParams(str: string): string {
QUERY_PARAM_RE.lastIndex = 0;
const match = str.match(SEGMENT_RE);
return match ? match[0] : '';
}

const QUERY_PARAM_VALUE_RE = /^[^\?&#]+/;
const QUERY_PARAM_VALUE_RE = /^[^?&#]+/;
// Return the value of the query param at the start of the string or an empty string
function matchUrlQueryParamValue(str: string): string {
QUERY_PARAM_VALUE_RE.lastIndex = 0;
const match = str.match(QUERY_PARAM_VALUE_RE);
Expand Down

0 comments on commit d75f170

Please sign in to comment.