<commit_before>﻿define(function(require) {
    var system = require('durandal/system'),
        viewEngine = require('durandal/viewEngine');

    return {
        locateViewForObject: function(obj) {
            var view;

            if (obj.getView) {
                view = obj.getView();
                if (view) {
                    return this.locateView(view);
                }
            }

            if (obj.viewUrl) {
                return this.locateView(obj.viewUrl);
            }

            var id = system.getModuleId(obj);
            if (id) {
                return this.locateView(this.convertModuleIdToViewUrl(id));
            }

            return this.locateView(this.determineFallbackViewUrl(obj));
        },
        convertModuleIdToViewUrl: function(moduleId) {
            return moduleId;
        },
        determineFallbackViewUrl: function(obj) {
            var funcNameRegex = /function (.{1,})\(/;
            var results = (funcNameRegex).exec((obj).constructor.toString());
            var typeName = (results && results.length > 1) ? results[1] : "";

            return 'views/' + typeName;
        },
        convertViewUrlToAreaUrl: function(area, viewUrl) {
            return viewUrl;
        },
        locateView: function(viewOrUrl, area) {
            var that = this;
            return system.defer(function(dfd) {
                if (typeof viewOrUrl === 'string') {
                    if (viewOrUrl.indexOf(viewEngine.viewExtension) != -1) {
                        viewOrUrl = viewOrUrl.substring(0, viewOrUrl.length - viewEngine.viewExtension.length);
                    }

                    if (area) {
                        viewOrUrl = that.convertViewUrlToAreaUrl(viewOrUrl);
                    }

                    var requirePath = viewEngine.pluginPath + '!' + viewOrUrl + viewEngine.viewExtension;

                    system.acquire(requirePath).then(function(result) {
                        dfd.resolve(viewEngine.createView(viewOrUrl, result));
                    });
                } else {
                    dfd.resolve(viewOrUrl);
                }
            }).promise();<commit_msg>Fixed a bug in view locator areas.<commit_after>﻿define(function(require) {
    var system = require('durandal/system'),
        viewEngine = require('durandal/viewEngine');

    return {
        locateViewForObject: function(obj) {
            var view;

            if (obj.getView) {
                view = obj.getView();
                if (view) {
                    return this.locateView(view);
                }
            }

            if (obj.viewUrl) {
                return this.locateView(obj.viewUrl);
            }

            var id = system.getModuleId(obj);
            if (id) {
                return this.locateView(this.convertModuleIdToViewUrl(id));
            }

            return this.locateView(this.determineFallbackViewUrl(obj));
        },
        convertModuleIdToViewUrl: function(moduleId) {
            return moduleId;
        },
        determineFallbackViewUrl: function(obj) {
            var funcNameRegex = /function (.{1,})\(/;
            var results = (funcNameRegex).exec((obj).constructor.toString());
            var typeName = (results && results.length > 1) ? results[1] : "";

            return 'views/' + typeName;
        },
        convertViewUrlToAreaUrl: function(area, viewUrl) {
            return viewUrl;
        },
        locateView: function(viewOrUrl, area) {
            var that = this;
            return system.defer(function(dfd) {
                if (typeof viewOrUrl === 'string') {
                    if (viewOrUrl.indexOf(viewEngine.viewExtension) != -1) {
                        viewOrUrl = viewOrUrl.substring(0, viewOrUrl.length - viewEngine.viewExtension.length);
                    }

                    if (area) {
                        viewOrUrl = that.convertViewUrlToAreaUrl(area, viewOrUrl);
                    }

                    var requirePath = viewEngine.pluginPath + '!' + viewOrUrl + viewEngine.viewExtension;

                    system.acquire(requirePath).then(function(result) {
                        dfd.resolve(viewEngine.createView(viewOrUrl, result));
                    });
                } else {
                    dfd.resolve(viewOrUrl);
                }
            }).promise();
{'fraction_non_alphanumeric': 0.1091573418588719, 'fraction_numerical': 0.0022836263987211693, 'mean_word_length': 1.4787775891341257, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2855018', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1113, 'n_words': 192}