Skip to content

Commit b00689b

Browse files
Properly handle base URL argument in URL constructor (#33)
Plus, more proper error handling for invalid URLs. "More proper" because we should generate more helpful error messages, but this is an improvement for now.
1 parent a6223d0 commit b00689b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.2.1 (2021-08-27)
2+
3+
### Fixes
4+
5+
- Properly support `base` argument in `URL` constructor
6+
[#33](https://github.com/fastly/js-compute-runtime/pull/33)
7+
18
## 0.2.0 (2021-08-24)
29

310
### Enhancements

c-dependencies/js-compute-runtime/js-compute-builtins.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -3777,7 +3777,7 @@ namespace URL {
37773777
auto str = encode(cx, base_val);
37783778
if (!str.data) return nullptr;
37793779

3780-
JSUrl* base = jsurl::new_jsurl(&str);
3780+
base = jsurl::new_jsurl(&str);
37813781
if (!base) {
37823782
JS_ReportErrorUTF8(cx, "URL constructor: %s is not a valid URL.", (char*)str.data);
37833783
return nullptr;
@@ -3794,6 +3794,11 @@ namespace URL {
37943794
url = jsurl::new_jsurl(&str);
37953795
}
37963796

3797+
if (!url) {
3798+
JS_ReportErrorUTF8(cx, "URL constructor: %s is not a valid URL.", (char*)str.data);
3799+
return nullptr;
3800+
}
3801+
37973802
JS::SetReservedSlot(self, Slots::Url, JS::PrivateValue(url));
37983803

37993804
return self;

0 commit comments

Comments
 (0)