Skip to content

Commit

Permalink
Fix navigateTo(): leading slashes case
Browse files Browse the repository at this point in the history
  • Loading branch information
Farfurix committed Feb 28, 2018
1 parent 7da06bd commit 09f8e24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import * as typeUtils from './utils/types';
import * as positionUtils from './utils/position';
import * as styleUtils from './utils/style';
import trim from '../utils/string-trim';
import { isRelativeUrl, parseProxyUrl, isSpecialPage, ensureOriginTrailingSlash } from '../utils/url';
import { isRelativeUrl, parseProxyUrl, isSpecialPage, ensureOriginTrailingSlash, LEADING_SLASHES_RE } from '../utils/url';
import * as urlUtils from './utils/url';
import * as featureDetection from './utils/feature-detection';
import * as htmlUtils from './utils/html';
Expand Down Expand Up @@ -197,10 +197,11 @@ class Hammerhead {
destLocation = parsedProxyUrl && parsedProxyUrl.destUrl;
}

if (isSpecialPage(destLocation) && isRelativeUrl(url))
if (destLocation === 'about:blank' && isRelativeUrl(url))
return;

url = ensureOriginTrailingSlash(url);
if (!LEADING_SLASHES_RE.test(url) && !isSpecialPage(url))
url = ensureOriginTrailingSlash(url);

const proxyUrl = urlUtils.getProxyUrl(url);

Expand Down
2 changes: 1 addition & 1 deletion src/utils/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import trim from './string-trim';

//Const
const PROTOCOL_RE = /^([\w-]+?:)(\/\/|[^\\/]|$)/;
const LEADING_SLASHES_RE = /^(\/\/)/;
const HOST_RE = /^(.*?)(\/|%|\?|;|#|$)/;
const PORT_RE = /:([0-9]*)$/;
const QUERY_AND_HASH_RE = /(\?.+|#[^#]*)$/;
const PATH_AFTER_HOST_RE = /^\/([^/]+?)\/([\S\s]+)$/;

export const SUPPORTED_PROTOCOL_RE = /^(?:https?|file):/i;
export const LEADING_SLASHES_RE = /^(\/\/)/;
export const HASH_RE = /^#/;
export const REQUEST_DESCRIPTOR_VALUES_SEPARATOR = '!';
export const TRAILING_SLASH_RE = /\/$/;
Expand Down

0 comments on commit 09f8e24

Please sign in to comment.