Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
Merge nodejs/master
Browse files Browse the repository at this point in the history
Merge e96ca62 as of 2017-08-06.
This is an automatically created merge. For any problems please
contact @kunalspathak.
  • Loading branch information
chakrabot committed Aug 8, 2017
2 parents a6205d3 + e96ca62 commit 4abaa11
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/node_url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ void URL::Parse(const char* input,
}
break;
case kNoScheme:
cannot_be_base = base->flags & URL_FLAGS_CANNOT_BE_BASE;
cannot_be_base = has_base && (base->flags & URL_FLAGS_CANNOT_BE_BASE);
if (!has_base || (cannot_be_base && ch != '#')) {
url->flags |= URL_FLAGS_FAILED;
return;
Expand Down
14 changes: 13 additions & 1 deletion test/cctest/test_url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "gtest/gtest.h"

using node::url::URL;
using node::url::URL_FLAGS_FAILED;

class URLTest : public ::testing::Test {
protected:
Expand All @@ -20,6 +21,7 @@ class URLTest : public ::testing::Test {
TEST_F(URLTest, Simple) {
URL simple("https://example.org:81/a/b/c?query#fragment");

EXPECT_FALSE(simple.flags() & URL_FLAGS_FAILED);
EXPECT_EQ(simple.protocol(), "https:");
EXPECT_EQ(simple.host(), "example.org");
EXPECT_EQ(simple.port(), 81);
Expand All @@ -32,6 +34,7 @@ TEST_F(URLTest, Simple2) {
const char* input = "https://example.org:81/a/b/c?query#fragment";
URL simple(input, strlen(input));

EXPECT_FALSE(simple.flags() & URL_FLAGS_FAILED);
EXPECT_EQ(simple.protocol(), "https:");
EXPECT_EQ(simple.host(), "example.org");
EXPECT_EQ(simple.port(), 81);
Expand All @@ -40,10 +43,17 @@ TEST_F(URLTest, Simple2) {
EXPECT_EQ(simple.fragment(), "fragment");
}

TEST_F(URLTest, NoBase1) {
URL error("123noscheme");
EXPECT_TRUE(error.flags() & URL_FLAGS_FAILED);
}

TEST_F(URLTest, Base1) {
URL base("http://example.org/foo/bar");
URL simple("../baz", &base);
ASSERT_FALSE(base.flags() & URL_FLAGS_FAILED);

URL simple("../baz", &base);
EXPECT_FALSE(simple.flags() & URL_FLAGS_FAILED);
EXPECT_EQ(simple.protocol(), "http:");
EXPECT_EQ(simple.host(), "example.org");
EXPECT_EQ(simple.path(), "/baz");
Expand All @@ -52,6 +62,7 @@ TEST_F(URLTest, Base1) {
TEST_F(URLTest, Base2) {
URL simple("../baz", "http://example.org/foo/bar");

EXPECT_FALSE(simple.flags() & URL_FLAGS_FAILED);
EXPECT_EQ(simple.protocol(), "http:");
EXPECT_EQ(simple.host(), "example.org");
EXPECT_EQ(simple.path(), "/baz");
Expand All @@ -63,6 +74,7 @@ TEST_F(URLTest, Base3) {

URL simple(input, strlen(input), base, strlen(base));

EXPECT_FALSE(simple.flags() & URL_FLAGS_FAILED);
EXPECT_EQ(simple.protocol(), "http:");
EXPECT_EQ(simple.host(), "example.org");
EXPECT_EQ(simple.path(), "/baz");
Expand Down

0 comments on commit 4abaa11

Please sign in to comment.