this.logger.info(_scope, 'finished', { ctx });
}
+
+ /**
+ * Determine if a profile url matches enough of a topic url to describe control over it.
+ * Topic must match hostname and start with the profile's path.
+ * @param {URL} profileUrlObj
+ * @param {URL} topicUrlObj
+ * @returns {Boolean}
+ */
+ static _profileControlsTopic(profileUrlObj, topicUrlObj) {
+ const hostnameMatches = profileUrlObj.hostname === topicUrlObj.hostname;
+ const pathIsPrefix = topicUrlObj.pathname.startsWith(profileUrlObj.pathname);
+ return hostnameMatches && pathIsPrefix;
+ }
+
+
/**
* GET request for authorized /admin information.
* @param {http.ServerResponse} res
const profileUrlObj = new URL(ctx.session.authenticatedProfile);
ctx.topics = ctx.topics.filter((topic) => {
const topicUrlObj = new URL(topic.url);
- return (topicUrlObj.hostname === profileUrlObj.hostname);
+ return Manager._profileControlsTopic(profileUrlObj, topicUrlObj);
});
}
if (ctx.session && ctx.session.authenticatedProfile) {
const profileUrlObj = new URL(ctx.session.authenticatedProfile);
const topicUrlObj = new URL(ctx.topic.url);
- if (topicUrlObj.hostname !== profileUrlObj.hostname) {
+ if (!Manager._profileControlsTopic(profileUrlObj, topicUrlObj)) {
ctx.topic = null;
ctx.subscriptions = [];
}